Skip to content

Commit 19e79e3

Browse files
committed
added core worksop content
1 parent 734546a commit 19e79e3

21 files changed

+25006
-1
lines changed

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.eslint*
2+
**/node_modules
3+
**/bower_components
4+
**/lib
5+
**/vendor
6+
**/*.min.js

.eslintrc.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* These rules enforce Hack Reactor's style guide.
3+
* Visit this repo for more information:
4+
* https://github.com/reactorcore/eslint-config-hackreactor
5+
*/
6+
7+
module.exports = {
8+
env: {
9+
'es6': true
10+
},
11+
parserOptions: {
12+
ecmaFeatures: {
13+
'jsx': true
14+
}
15+
},
16+
rules: {
17+
/* Indentation */
18+
'no-mixed-spaces-and-tabs': 2,
19+
'indent': [2, 2],
20+
/* Variable cames */
21+
'camelcase': 2,
22+
/* Language constructs */
23+
'curly': 2,
24+
'eqeqeq': [2, 'smart'],
25+
'func-style': [2, 'expression'],
26+
/* Semicolons */
27+
'semi': 2,
28+
'no-extra-semi': 2,
29+
/* Padding & additional whitespace (perferred but optional) */
30+
'brace-style': [2, '1tbs', { 'allowSingleLine': true }],
31+
'semi-spacing': 1,
32+
'key-spacing': 1,
33+
'block-spacing': 1,
34+
'comma-spacing': 1,
35+
'no-multi-spaces': 1,
36+
'space-before-blocks': 1,
37+
'keyword-spacing': [1, { 'before': true, 'after': true }],
38+
'space-infix-ops': 1,
39+
/* Variable declaration */
40+
'one-var': [1, { 'uninitialized': 'always', 'initialized': 'never' }],
41+
/* Minuta */
42+
'comma-style': [2, 'last'],
43+
'quotes': [1, 'single']
44+
}
45+
};

.gitignore

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
### node etc ###
2+
3+
# Logs
4+
logs
5+
*.log
6+
7+
# Runtime data
8+
pids
9+
*.pid
10+
*.seed
11+
12+
# Directory for instrumented libs generated by jscoverage/JSCover
13+
lib-cov
14+
15+
# Coverage directory used by tools like istanbul
16+
coverage
17+
18+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
19+
.grunt
20+
21+
# Compiled Dirs (http://nodejs.org/api/addons.html)
22+
build/
23+
dist/
24+
25+
# Dependency directorys
26+
# Deployed apps should consider commenting these lines out:
27+
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
28+
node_modules/
29+
bower_components/
30+
31+
# Floobits
32+
.floo
33+
.floobit
34+
.floo
35+
.flooignore

README.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,82 @@ No textbook is required for this workshop. All materials are included in this Gi
1212

1313
## Technical requirements
1414

15-
Laptop, Google Chrome browser and a text editor. If you do not have a text editor, we recommend Sublime Text, Atom or Visual Studio Code.
15+
Laptop, Google Chrome browser and a text editor. If you do not have a text editor, we recommend Visual Studio Code, Sublime Text, or Atom.
1616

1717
# How to use this repository
1818

1919
### Let's get started...
2020

21+
Run the SpecRunner.html file in a browser. This document shows 4 failing tests.
22+
23+
The `spec` folder holds all the failing tests that are being displayed in SpecRunner.html. The `src` folder holds the functions that are being called to run the tests. Your task is to edit the filed in `src` to complete the functions and get the tests to pass. These files are just javascript files so you can use console.log to help debug and inspect these functions.
24+
25+
## Recursion Review
26+
27+
Recursion is a technique for solving problems wherein a function makes calls to itself. By doing so, it can complete a small amount of the processing, and delegate the rest of the problem to the recursive calls.
28+
29+
Consider the following function:
30+
31+
```
32+
var eat = function(meal){
33+
console.log('meal before bite:', meal);
34+
console.log('now eating', meal.pop());
35+
if(meal.length){
36+
eat(meal);
37+
} else {
38+
console.log('done with the meal!');
39+
}
40+
}
41+
```
42+
43+
Which produces this output:
44+
45+
```
46+
eat(['soup', 'potatoes', 'fish']);
47+
// => meal before bite: ["soup", "potatoes", "fish"]
48+
// => now eating fish
49+
// => meal before bite: ["soup", "potatoes"]
50+
// => now eating potatoes
51+
// => meal before bite: ["soup"]
52+
// => now eating soup
53+
// => done with the meal!
54+
```
55+
56+
You can use recursion on problems where smaller parts of the problem look the same as the larger problem as a whole.
57+
58+
In this sprint, you'll be practicing writing recursive functions, building up to the reimplementation of a JavaScript browser method that involves recursion (getElementsByClassName). In so doing, don't use the things you're reimplementing, or any other built-in shortcuts that make these problems trivial. (You'll probably know if you're cheating, but feel free to ask us if you're not sure.)
59+
60+
(Curious fact: many browsers don't have any of these functions in them, and people do need to reimplement them. When we reimplement new browser functionality in older browsers, it's called a "polyfill".)
61+
62+
## Exercises
63+
64+
### 1: sumArray
65+
66+
- [ ] Implement `sumArray` with your own function in `src/sumArray.js`
67+
68+
### 2: power
69+
70+
- [ ] Implement `power` with your own function in `src/power.js`
71+
72+
### 3: nthFibonacci
73+
74+
- [ ] Implement `nthFibonacci` with your own function in `src/nthFibonacci.js`
75+
76+
### 4: getElementsByClassName
77+
78+
- [ ] Implement `getElementsByClassName` with your own function in `src/getElementsByClassName.js`
79+
- [ ] You should use `document.body`, `element.childNodes`, and `element.classList`
80+
- NOTE: You may also use methods from the [underscore](https://underscorejs.org) library for assitance, but are not required to do so.
81+
- You can view the MDN documentation for getElementsByClassName [here](https://developer.mozilla.org/en/docs/Web/API/Document/getElementsByClassName)
82+
2183
#### Failing Test Example
2284

85+
![failing tests](images/failing-tests.png)
86+
2387
#### Passing Test Example
2488

89+
![passing tests](images/passing-tests.png)
90+
2591
### Don't forget..
2692

2793
You should throroughly read all of code in front of you and aim to understand line-by-line what is happening.

SpecRunner.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<title>Mocha Spec Runner</title>
5+
<link rel="stylesheet" href="lib/mocha/mocha.css">
6+
<script src="lib/jquery.js"></script>
7+
<script src="lib/underscore.js"></script>
8+
<script src="lib/mocha/mocha.js"></script>
9+
<script src="lib/chai/chai.js"></script>
10+
<script src="lib/sinon/sinon.js"></script>
11+
<script>
12+
mocha.setup({ui: 'bdd'});
13+
window.expect = chai.expect;
14+
$(function() {
15+
window.mochaPhantomJS ? mochaPhantomJS.run() : mocha.run();
16+
});
17+
</script>
18+
<script src="src/sumArray.js"></script>
19+
<script src="src/power.js"></script>
20+
<script src="src/nthFibonacci.js"></script>
21+
<script src="src/getElementsByClassName.js"></script>
22+
<script src="spec/sumArraySpec.js"></script>
23+
<script src="spec/powerSpec.js"></script>
24+
<script src="spec/nthFibonacciSpec.js"></script>
25+
<script src="spec/getElementsByClassNameSpec.js"></script>
26+
</head>
27+
<body>
28+
<div id="mocha"></div>
29+
</body>
30+
</html>
31+

images/failing-tests.png

149 KB
Loading

images/passing-tests.png

78.4 KB
Loading

0 commit comments

Comments
 (0)