diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/record-collection.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/record-collection.english.md index 0a4030d013..cf330d6e45 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/record-collection.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/basic-javascript/record-collection.english.md @@ -30,20 +30,22 @@ You may refer back to updateRecords(5439, "artist", "ABBA"), artist should be "ABBA" - testString: collection = collectionCopy; assert(updateRecords(5439, "artist", "ABBA")[5439]["artist"] === "ABBA", 'After updateRecords(5439, "artist", "ABBA"), artist should be "ABBA"'); + testString: assert(updateRecords(5439, "artist", "ABBA")[5439]["artist"] === "ABBA"); - text: After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element. - testString: assert(updateRecords(5439, "tracks", "Take a Chance on Me")[5439]["tracks"].pop() === "Take a Chance on Me", 'After updateRecords(5439, "tracks", "Take a Chance on Me"), tracks should have "Take a Chance on Me" as the last element.'); + testString: assert(updateRecords(5439, "tracks", "Take a Chance on Me")[5439]["tracks"].pop() === "Take a Chance on Me"); - text: After updateRecords(2548, "artist", ""), artist should not be set - testString: updateRecords(2548, "artist", ""); assert(!collection[2548].hasOwnProperty("artist"), 'After updateRecords(2548, "artist", ""), artist should not be set'); + testString: updateRecords(2548, "artist", ""); assert(!collection[2548].hasOwnProperty("artist")); - text: After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element. - testString: assert(updateRecords(1245, "tracks", "Addicted to Love")[1245]["tracks"].pop() === "Addicted to Love", 'After updateRecords(1245, "tracks", "Addicted to Love"), tracks should have "Addicted to Love" as the last element.'); + testString: assert(updateRecords(1245, "tracks", "Addicted to Love")[1245]["tracks"].pop() === "Addicted to Love"); - text: After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element. - testString: assert(updateRecords(2468, "tracks", "Free")[2468]["tracks"][0] === "1999", 'After updateRecords(2468, "tracks", "Free"), tracks should have "1999" as the first element.'); + testString: assert(updateRecords(2468, "tracks", "Free")[2468]["tracks"][0] === "1999"); - text: After updateRecords(2548, "tracks", ""), tracks should not be set - testString: updateRecords(2548, "tracks", ""); assert(!collection[2548].hasOwnProperty("tracks"), 'After updateRecords(2548, "tracks", ""), tracks should not be set'); + testString: updateRecords(2548, "tracks", ""); assert(!collection[2548].hasOwnProperty("tracks")); - text: After updateRecords(1245, "album", "Riptide"), album should be "Riptide" - testString: assert(updateRecords(1245, "album", "Riptide")[1245]["album"] === "Riptide", 'After updateRecords(1245, "album", "Riptide"), album should be "Riptide"'); + testString: assert(updateRecords(1245, "album", "Riptide")[1245]["album"] === "Riptide"); ``` @@ -51,38 +53,35 @@ tests: ## Challenge Seed
-
```js // Setup var collection = { - "2548": { - "album": "Slippery When Wet", - "artist": "Bon Jovi", - "tracks": [ - "Let It Rock", - "You Give Love a Bad Name" - ] - }, - "2468": { - "album": "1999", - "artist": "Prince", - "tracks": [ - "1999", - "Little Red Corvette" - ] - }, - "1245": { - "artist": "Robert Palmer", - "tracks": [ ] - }, - "5439": { - "album": "ABBA Gold" - } + 2548: { + album: "Slippery When Wet", + artist: "Bon Jovi", + tracks: [ + "Let It Rock", + "You Give Love a Bad Name" + ] + }, + 2468: { + album: "1999", + artist: "Prince", + tracks: [ + "1999", + "Little Red Corvette" + ] + }, + 1245: { + artist: "Robert Palmer", + tracks: [ ] + }, + 5439: { + album: "ABBA Gold" + } }; -// Keep a copy of the collection for tests -var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function updateRecords(id, prop, value) { @@ -97,51 +96,37 @@ updateRecords(5439, "artist", "ABBA"); ```
- - -### After Test -
- -```js -;(function(x) { return "collection = \n" + JSON.stringify(x, '\n', 2); })(collection); -``` - -
-
## Solution
- ```js var collection = { - 2548: { - album: "Slippery When Wet", - artist: "Bon Jovi", - tracks: [ - "Let It Rock", - "You Give Love a Bad Name" - ] - }, - 2468: { - album: "1999", - artist: "Prince", - tracks: [ - "1999", - "Little Red Corvette" - ] - }, - 1245: { - artist: "Robert Palmer", - tracks: [ ] - }, - 5439: { - album: "ABBA Gold" - } + 2548: { + album: "Slippery When Wet", + artist: "Bon Jovi", + tracks: [ + "Let It Rock", + "You Give Love a Bad Name" + ] + }, + 2468: { + album: "1999", + artist: "Prince", + tracks: [ + "1999", + "Little Red Corvette" + ] + }, + 1245: { + artist: "Robert Palmer", + tracks: [ ] + }, + 5439: { + album: "ABBA Gold" + } }; -// Keep a copy of the collection for tests -var collectionCopy = JSON.parse(JSON.stringify(collection)); // Only change code below this line function updateRecords(id, prop, value) {