Skip to content

Commit 0dfd9ae

Browse files
committed
init demo updates
1 parent c2dc873 commit 0dfd9ae

File tree

6 files changed

+48
-30
lines changed

6 files changed

+48
-30
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Some basic methods in Javascript
2525

2626
##### Filter
2727

28-
Last semester's grades just came in, but there's just too much data.
28+
We'll start by looking at the `filter` method.
2929

3030
##### Map
3131

32-
Now that we've filtered down our data, let's make some changes.
32+
Map is used to run a function over data in an array.

coderoad.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"pages": [
1010
{
1111
"title": "Filter",
12-
"description": "Last semester's grades just came in, but there's just too much data.",
13-
"explanation": "Use the `filter` method to shorten the data to only what you need.\n\n```\n['a', 'b', 'c'].filter(function(item) {\n return item === 'a';\n});\n// ['a']\n```",
12+
"description": "We'll start by looking at the `filter` method.",
13+
"explanation": "Last semester's grades just came in, but there's just too much data.\n\nUse the `filter` method to shorten the data to only what you need.\n\n```\n['a', 'b', 'c'].filter(function(item) {\n return item === 'a';\n});\n// ['a']\n```",
1414
"tasks": [
1515
{
1616
"description": "Set `var myData` equal to `filter`ed down data with your name: \"Jane\".",
@@ -19,24 +19,28 @@
1919
],
2020
"actions": [
2121
"open('filter.js')",
22-
"('')",
23-
"insert('var data = [ { name: \"Joe\", class: \"Computer Science\", grade: \"C\" }, { name: \"Jane\", class: \"Computer Science\", grade: \"D\" }, { name: \"Mo\", class: \"Computer Science\", grade: \"B\" }, { name: \"Bob\", class: \"Computer Science\", grade: \"F\" }, { name: \"Joe\", class: \"Math\", grade: \"C\" }, { name: \"Jane\", class: \"Math\", grade: \"B\" }, { name: \"Mo\", class: \"Math\", grade: \"D\" }, { name: \"Bob\", class: \"Math\", grade: \"A\" }, { name: \"Joe\", class: \"Art\", grade: \"C\" }, { name: \"Jane\", class: \"Art\", grade: \"F\" }, { name: \"Mo\", class: \"Art\", grade: \"B\" }, { name: \"Bob\", class: \"Math\", grade: \"F\" }, ]')"
22+
"set('var data = [\n { name: \"Joe\", class: \"Computer Science\", grade: \"C\" },\n { name: \"Jane\", class: \"Computer Science\", grade: \"D\" },\n { name: \"Mo\", class: \"Computer Science\", grade: \"B\" },\n { name: \"Bob\", class: \"Computer Science\", grade: \"F\" },\n { name: \"Joe\", class: \"Math\", grade: \"C\" },\n { name: \"Jane\", class: \"Math\", grade: \"B\" },\n { name: \"Mo\", class: \"Math\", grade: \"D\" },\n { name: \"Bob\", class: \"Math\", grade: \"A\" },\n { name: \"Joe\", class: \"Art\", grade: \"C\" },\n { name: \"Jane\", class: \"Art\", grade: \"F\" },\n { name: \"Mo\", class: \"Art\", grade: \"B\" },\n { name: \"Bob\", class: \"Math\", grade: \"F\" }\n];\n')",
23+
"insert('var myData = data.filter(function(item) {\n return // filter condition\n});')"
2424
]
2525
},
2626
{
27-
"description": "Set `var myFails` to `filter`ed down data with failing grades (\"D\" or \"F\").",
27+
"description": "Set `var myFails` to `filter`ed down your data to find only your failing grades (\"D\" or \"F\").",
2828
"tests": [
2929
"1/filter/filter-02"
30+
],
31+
"actions": [
32+
"insert('var myFails = myData.filter(\n// add filter here\n)')"
3033
]
3134
}
3235
]
3336
},
3437
{
3538
"title": "Map",
36-
"description": "Now that we've filtered down our data, let's make some changes."
39+
"description": "Map is used to run a function over data in an array.",
40+
"explanation": "Now that we've filtered down our data, let's make some changes."
3741
}
3842
],
3943
"description": "Some basic methods in Javascript"
4044
}
4145
]
42-
}
46+
}

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
var expect = require('chai').expect;
21

2+
var expect = require('chai').expect;
33
// use to ensure a specific method has been called
4-
var spies = require('chai-spies');
5-
chai.use(spies);
4+
// var spies = require('chai-spies');
65

76
// loads file context to allow globals
87
var context = require('test-context');
9-
var filePath = path.join('..', '..', '..', 'filter.js');
8+
var filePath = '../../../../../filter.js';
109
context(filePath);
1110

1211
describe('var myData', function() {
@@ -23,16 +22,16 @@ describe('var myData', function() {
2322
expect(myData.length).to.equal(3);
2423
});
2524

26-
it('should use the array filter method', function() {
27-
var spy = chai.spy.on(data, 'filter');
28-
expect(spy).to.be(true);
29-
});
25+
// it('should use the array filter method', function() {
26+
// var spy = chai.spy.on(data, 'filter');
27+
// expect(spy).to.be(true);
28+
// });
3029

3130
it('isn\'t the right data for Jane', function() {
32-
expect(myData).to.equal([
31+
expect(myData).to.deep.equal([
3332
{ name: "Jane", class: "Computer Science", grade: "D" },
3433
{ name: "Jane", class: "Math", grade: "B" },
35-
{ name: "Jane", class: "Art", grade: "A" }
34+
{ name: "Jane", class: "Art", grade: "F" }
3635
]);
3736
});
3837

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
12
var expect = require('chai').expect;
23
var context = require('test-context');
3-
var filePath = path.join('..', '..', '..', 'filter.js');
4-
context(filePath);
4+
context('../../../../../filter.js');
55

66
describe('var myData', function() {
77

@@ -13,12 +13,12 @@ describe('var myData', function() {
1313
expect(myFails).to.be.an('array');
1414
});
1515

16-
it('doesn\'t have three items', function() {
16+
it('doesn\'t have exactly two items', function() {
1717
expect(myFails.length).to.equal(2);
1818
});
1919

2020
it('isn\'t the right data for Jane', function() {
21-
expect(myData).to.equal([
21+
expect(myFails).to.deep.equal([
2222
{ name: "Jane", class: "Computer Science", grade: "D" },
2323
{ name: "Jane", class: "Art", grade: "F" }
2424
]);

tutorial/1/filter/filter.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
### Filter
2+
We'll start by looking at the `filter` method.
3+
24
Last semester's grades just came in, but there's just too much data.
35

46
Use the `filter` method to shorten the data to only what you need.
@@ -13,10 +15,9 @@ Use the `filter` method to shorten the data to only what you need.
1315
+ Set `var myData` equal to `filter`ed down data with your name: "Jane".
1416
@test('1/filter/filter-01')
1517
@action(open('filter.js'))
16-
@action(insert('// Welcome'));
17-
@action(insert(
18-
```
19-
var data = [
18+
@action(set(
19+
```
20+
var data = [
2021
{ name: "Joe", class: "Computer Science", grade: "C" },
2122
{ name: "Jane", class: "Computer Science", grade: "D" },
2223
{ name: "Mo", class: "Computer Science", grade: "B" },
@@ -27,10 +28,22 @@ Use the `filter` method to shorten the data to only what you need.
2728
{ name: "Bob", class: "Math", grade: "A" },
2829
{ name: "Joe", class: "Art", grade: "C" },
2930
{ name: "Jane", class: "Art", grade: "F" },
30-
{ name: "Mo", class: "Art", grade: "B" }, { name: "Bob", class: "Math", grade: "F" },
31-
]
31+
{ name: "Mo", class: "Art", grade: "B" },
32+
{ name: "Bob", class: "Math", grade: "F" }
33+
];
34+
3235
```
3336
))
37+
@action(insert(
38+
```
39+
var myData = data.filter(function(item) {
40+
return // filter condition
41+
});
42+
```))
3443
35-
+ Set `var myFails` to `filter`ed down data with failing grades ("D" or "F").
44+
+ Set `var myFails` to `filter`ed down your data to find only your failing grades ("D" or "F").
3645
@test('1/filter/filter-02')
46+
@action(insert(
47+
```
48+
var myFails = myData.filter() // add filter here
49+
```))

tutorial/1/map/map.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
### Map
2+
Map is used to run a function over data in an array.
3+
24
Now that we've filtered down our data, let's make some changes.

0 commit comments

Comments
 (0)