Skip to content

Commit 0bf6653

Browse files
committed
Merge pull request #1 from dimchez/03-map-typo-fix
Fixed function name
2 parents ca28f8f + 21023cd commit 0bf6653

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

coderoad.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"description": "Array -> run a function over each item -> Array\n\nYou've filtered and sorted our data, but neither of those actually change the data.\n\nWouldn't it be simpler if you could just change your grades?\n\nYou can use the array method `map` to run a function that returns changes to your data.\n\nAs an example, let's look at how you would increment each number in an array.\n\n```js\nfunction addOne(num) {\n return num + 1;\n}\n\n[1, 2, 3].map(addOne);\n//> [2, 3, 4]\n\nfunction addToVal(obj) {\n obj.val += 1;\n return obj;\n}\n[{ val: 1}].map(addToVal);\n//> [{ val: 2 }]\n```\n\n`map` can change data, and it can also alter structure of the data you're working with.\n\n```js\nfunction makeObject(num) {\n return { val: num };\n}\n\n[1, 2].map(makeObject);\n//> [{ val: 1 }, { val: 2 }]\n```\n\nSimilarly, `map` can also restrict the data you want to work with. See the example below to see another way scores could be sorted.\n\n```js\nmyBest\n .map(function(student) {\n return student.score;\n })\n .sort()\n .reverse()\n//> [93, 91, 88, 88, 82, 81, 73]\n```\n\nIn this example, `map` transformed an object with keys of 'title', 'instructor', 'name', 'score' and 'grade', to an array of just scores. Values weren't changed, but rather limited to a smaller subset of scores.\n\n`map` is powerful. Let's see what you can do with it.\n\nThose D & F grades would look a lot better if they suddenly became A's.\n\nLet's go back to before we filtered out the bad grades, and instead change the grades to A's.",
121121
"tasks": [
122122
{
123-
"description": "Make a function `changeGrades` that takes student data and changes all grades to \"A\"s.",
123+
"description": "Make a function `changeGrade` that takes student data and changes all grades to \"A\"s.",
124124
"tests": [
125125
"1/03/01-map"
126126
],
@@ -135,12 +135,12 @@
135135
]
136136
},
137137
{
138-
"description": "Map over the `myData` with the `changeGrades` function. Set `myChanged` to the result.",
138+
"description": "Map over the `myData` with the `changeGrade` function. Set `myChanged` to the result.",
139139
"tests": [
140140
"1/03/02-map"
141141
],
142142
"actions": [
143-
"insert('// map over `myData` with the `changeGrades` function\nvar myChanged = myData.map();\n')"
143+
"insert('// map over `myData` with the `changeGrade` function\nvar myChanged = myData.map();\n')"
144144
]
145145
},
146146
{
@@ -486,4 +486,4 @@
486486
]
487487
}
488488
]
489-
}
489+
}

tutorial/1/03/map.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Those D & F grades would look a lot better if they suddenly became A's.
5656

5757
Let's go back to before we filtered out the bad grades, and instead change the grades to A's.
5858

59-
+ Make a function `changeGrades` that takes student data and changes all grades to "A"s.
59+
+ Make a function `changeGrade` that takes student data and changes all grades to "A"s.
6060
@test('1/03/01-map')
6161
@action(open('03-map.js'))
6262
@action(set(
@@ -72,11 +72,11 @@ function changeGrade() {
7272
@hint('match where `student.grade === 'A'`')
7373

7474

75-
+ Map over the `myData` with the `changeGrades` function. Set `myChanged` to the result.
75+
+ Map over the `myData` with the `changeGrade` function. Set `myChanged` to the result.
7676
@test('1/03/02-map')
7777
@action(insert(
7878
```
79-
// map over `myData` with the `changeGrades` function
79+
// map over `myData` with the `changeGrade` function
8080
var myChanged = myData.map();
8181
```
8282
))

0 commit comments

Comments
 (0)