Skip to content

Commit 68c09d5

Browse files
committed
setup & page 1
1 parent 2256592 commit 68c09d5

File tree

16 files changed

+1017
-37
lines changed

16 files changed

+1017
-37
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,29 @@ By the end, you should have an understanding of how to use array methods to mani
2929

3030
Array -> Array of items that match a condition
3131

32+
##### Sort
33+
34+
Array -> sorted Array
35+
3236
##### Map
3337

34-
Map is used to run a function over data in an array.
38+
Array -> run a function over each item -> Array
3539

3640
##### forEach
3741

38-
coming soon
42+
Array -> run a function for each item
3943

4044
##### find
4145

42-
coming soon
46+
Array -> find an item that matches a condition
4347

4448
##### concat
4549

46-
coming soon
50+
Array + Array -> Array
4751

4852
##### reduce
4953

50-
coming soon
54+
Array -> transform into anything
5155

5256
##### Challenge 1
5357

coderoad.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@
4242
}
4343
]
4444
},
45+
{
46+
"title": "Sort",
47+
"description": "Array -> sorted Array"
48+
},
4549
{
4650
"title": "Map",
47-
"description": "Map is used to run a function over data in an array.",
51+
"description": "Array -> run a function over each item -> Array",
4852
"explanation": "```\n[1, 2, 3].map(function(num) {\n return num + 1;\n});\n// [2, 3, 4]\n```\n\nNow that we've filtered down our data, let's make some changes. Those D & F's would look a lot better if they suddenly became A's.",
4953
"tasks": [
5054
{
@@ -68,19 +72,19 @@
6872
},
6973
{
7074
"title": "forEach",
71-
"description": "coming soon"
75+
"description": "Array -> run a function for each item"
7276
},
7377
{
7478
"title": "find",
75-
"description": "coming soon"
79+
"description": "Array -> find an item that matches a condition"
7680
},
7781
{
7882
"title": "concat",
79-
"description": "coming soon"
83+
"description": "Array + Array -> Array"
8084
},
8185
{
8286
"title": "reduce",
83-
"description": "coming soon"
87+
"description": "Array -> transform into anything"
8488
},
8589
{
8690
"title": "Challenge 1",

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
"chai": "3.5.0",
1313
"chai-spies": "0.7.1",
1414
"lodash": "4.3.0",
15-
"mocha": "2.4.5"
15+
"mocha": "2.4.5",
16+
"mocha-coderoad": "0.1.0"
1617
},
1718
"license": "MIT",
1819
"coderoad": {
1920
"testDir": "tutorial",
20-
"testSuffix": ".spec.js"
21+
"testSuffix": ".spec.js",
22+
"testRunner": "mocha-coderoad"
2123
}
2224
}

tutorial/1/01/01-filter.spec.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
var expect = require('chai').expect;
22
var path = require('path');
3-
// run test file in the context of 01-filter.js
4-
var loadContext = require('../../common/loadContext');
5-
var filePath = path.join(process.env.DIR, '01-filter.js');
6-
// global.data = require(process.env.TUTORIAL_DIR + '/tutorial/data/students').slice(0);
7-
8-
loadContext(filePath);
3+
var loadJS = require('../../common/loadJS').default;
4+
if (!global.data) {
5+
global.data = JSON.parse(JSON.stringify(require('./data.json')));
6+
}
7+
loadJS('01-filter.js');
98

109
describe('isAda', function() {
1110

tutorial/1/01/02-filter.spec.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
var expect = require('chai').expect;
22
var path = require('path');
3-
var loadContext = require('../../common/loadContext');
4-
var filePath = path.join(process.env.DIR, '01-filter.js');
5-
loadContext(filePath);
6-
global.data = require(process.env.TUTORIAL_DIR + '/tutorial/data/students').slice(0);
3+
var loadJS = require('../../common/loadJS').default;
4+
if (!global.data) {
5+
global.data = JSON.parse(JSON.stringify(require('./data.json')));
6+
}
7+
loadJS('01-filter.js');
78

89
describe('var myData', function() {
910

@@ -21,7 +22,7 @@ describe('var myData', function() {
2122

2223
it('isn\'t the right filtered data for "Ada Lovelace"', function() {
2324
var values = [91, 88, 61, 81, 73, 58, 93, 82, 88, 65];
24-
myVals = myBest.map(function(x) {
25+
myVals = myData.map(function(x) {
2526
return x.score;
2627
});
2728
values.forEach(function(value) {

tutorial/1/01/03-filter.spec.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
var expect = require('chai').expect;
22
var path = require('path');
3-
var loadContext = require('../../common/loadContext');
4-
var filePath = path.join(process.env.DIR, '01-filter.js');
5-
// global.data = require(process.env.TUTORIAL_DIR + '/tutorial/data/students').slice(0);
3+
var loadJS = require('../../common/loadJS').default;
4+
if (!global.data) {
5+
global.data = JSON.parse(JSON.stringify(require('./data.json')));
6+
}
7+
loadJS('01-filter.js');
68

79
describe('var myBest', function() {
810

0 commit comments

Comments
 (0)