You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: coderoad.json
+21-12Lines changed: 21 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -1,35 +1,44 @@
1
1
{
2
2
"project": {
3
3
"title": "Functional School",
4
-
"description": "A trip through functional programming."
4
+
"description": "A trip through functional programming in Javascript."
5
5
},
6
6
"chapters": [
7
7
{
8
-
"title": "The Basics",
8
+
"title": "Array Methods",
9
9
"pages": [
10
10
{
11
11
"title": "Filter",
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```",
12
+
"description": "Array -> Array of items that match a condition",
13
+
"explanation": "You've hacked into the school's computer system, and just in time. The grades are in, aren't you're not too proud of your performance. But that's okay, you have a plan: you're going to create a fake report card.\n\nIt would be great if you could `filter` the scores that your parents will see. A `filter` takes a matching condition function and only returns items that result in true. As an example, look at `isB` below:\n\n```\nfunction isB(x) {\n return x === 'b';\n}\n```\n\nLike all of the methods in this chapter, `filter` is already part of the `Array.prototype`, so you can run it after any array. Each item is passed into the params of the condition function, one by one.\n\n```\nvar list = ['a', 'b', 'c'];\nlist.filter(isB);\n//> ['b']\n```\n\nThere's too much student data in the computer system. We'll have to sort through it. Have a look at an example below:\n\n```\nconsole.log(studentData[0]);\n//> { course: 'Web Security',\n// instructor: 'Sue Denim',\n// name: 'Rebecca Heineman',\n// score: 93,\n// grade: 'A' }\n```",
14
14
"tasks": [
15
15
{
16
-
"description": "Set `var myData` equal to `filter`ed down data with your name: \"Jane\".",
16
+
"description": "Write a filter condition function called `isAda` that returns true if param.`name` is true",
"insert('var myBest = myData.filter// filter out \"D\"'s and \"F\"'s here\n')"
33
42
]
34
43
}
35
44
]
@@ -83,7 +92,7 @@
83
92
"description": "coming soon"
84
93
}
85
94
],
86
-
"description": "Some basic methods in Javascript"
95
+
"description": "Using common built-in Javascript array methods such as `map` & `reduce`.\n\nBy the end, you should have an understanding of how to use array methods to manipulate semi-complex data."
You've hacked into the school's computer system, and just in time. The grades are in, aren't you're not too proud of your performance. But that's okay, you have a plan: you're going to create a fake report card.
5
+
6
+
It would be great if you could `filter` the scores that your parents will see. A `filter` takes a matching condition function and only returns items that result in true. As an example, look at `isB` below:
7
+
8
+
```
9
+
function isB(x) {
10
+
return x === 'b';
11
+
}
12
+
```
13
+
14
+
15
+
Like all of the methods in this chapter, `filter` is already part of the `Array.prototype`, so you can run it after any array. Each item is passed into the params of the condition function, one by one.
16
+
17
+
```
18
+
var list = ['a', 'b', 'c'];
19
+
list.filter(isB);
20
+
//> ['b']
21
+
```
22
+
23
+
24
+
There's too much student data in the computer system. We'll have to sort through it. Have a look at an example below:
25
+
26
+
```
27
+
console.log(studentData[0]);
28
+
//> { course: 'Web Security',
29
+
// instructor: 'Sue Denim',
30
+
// name: 'Rebecca Heineman',
31
+
// score: 93,
32
+
// grade: 'A' }
33
+
```
34
+
35
+
+ Write a filter condition function called `isAda` that returns true if param.`name` is true
36
+
@test('1/01/01-filter')
37
+
@action(open('01-filter.js'))
38
+
@action(set(
39
+
```
40
+
function isAda(x) {
41
+
// write condition here
42
+
// the name must match "Ada Lovelace"
43
+
}
44
+
```))
45
+
46
+
+ Set `var myData` equal to data matching your name, "Ada Lovelace".
47
+
@test('1/01/02-filter')
48
+
@action(insert(
49
+
```
50
+
var data = require('./tutorial/data/students')(require('./tutorial/data/courses.json')).slice(0);
51
+
```))
52
+
@action(insert(
53
+
```
54
+
var myData = data.filter // call filter condition here
55
+
```))
56
+
57
+
+ Set `var myBest` to your scores, excluding any grades that are "D" or "F".
58
+
59
+
@test('1/01/03-filter')
60
+
@action(insert(
61
+
```
62
+
var myBest = myData.filter // filter out "D"'s and "F"'s here
0 commit comments