From a9c5c7d7fe6355865850b291f324a9ef41e0367b Mon Sep 17 00:00:00 2001 From: dimchez Date: Thu, 3 Mar 2016 10:29:01 +0100 Subject: [PATCH 1/2] Updated function name in comments and description Updated changeGrades to changeGrade in comments and description to match actual function name in the code. --- coderoad.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coderoad.json b/coderoad.json index a6b3c07..368b59c 100644 --- a/coderoad.json +++ b/coderoad.json @@ -120,7 +120,7 @@ "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.", "tasks": [ { - "description": "Make a function `changeGrades` that takes student data and changes all grades to \"A\"s.", + "description": "Make a function `changeGrade` that takes student data and changes all grades to \"A\"s.", "tests": [ "1/03/01-map" ], @@ -135,12 +135,12 @@ ] }, { - "description": "Map over the `myData` with the `changeGrades` function. Set `myChanged` to the result.", + "description": "Map over the `myData` with the `changeGrade` function. Set `myChanged` to the result.", "tests": [ "1/03/02-map" ], "actions": [ - "insert('// map over `myData` with the `changeGrades` function\nvar myChanged = myData.map();\n')" + "insert('// map over `myData` with the `changeGrade` function\nvar myChanged = myData.map();\n')" ] }, { @@ -486,4 +486,4 @@ ] } ] -} \ No newline at end of file +} From 21023cd16fc6ae547aebf54708f77ff3fb2ec8a0 Mon Sep 17 00:00:00 2001 From: dimchez Date: Thu, 3 Mar 2016 10:33:10 +0100 Subject: [PATCH 2/2] Updated function name Updated function name in comments to match function name in the code --- tutorial/1/03/map.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutorial/1/03/map.md b/tutorial/1/03/map.md index 25f6fed..7d31a98 100644 --- a/tutorial/1/03/map.md +++ b/tutorial/1/03/map.md @@ -56,7 +56,7 @@ Those D & F grades would look a lot better if they suddenly became A's. Let's go back to before we filtered out the bad grades, and instead change the grades to A's. -+ Make a function `changeGrades` that takes student data and changes all grades to "A"s. ++ Make a function `changeGrade` that takes student data and changes all grades to "A"s. @test('1/03/01-map') @action(open('03-map.js')) @action(set( @@ -72,11 +72,11 @@ function changeGrade() { @hint('match where `student.grade === 'A'`') -+ Map over the `myData` with the `changeGrades` function. Set `myChanged` to the result. ++ Map over the `myData` with the `changeGrade` function. Set `myChanged` to the result. @test('1/03/02-map') @action(insert( ``` -// map over `myData` with the `changeGrades` function +// map over `myData` with the `changeGrade` function var myChanged = myData.map(); ``` ))