diff --git a/seed/challenges/01-front-end-development-certification/basic-javascript.json b/seed/challenges/01-front-end-development-certification/basic-javascript.json index c5391ba665..2c86b6531c 100644 --- a/seed/challenges/01-front-end-development-certification/basic-javascript.json +++ b/seed/challenges/01-front-end-development-certification/basic-javascript.json @@ -928,7 +928,7 @@ "description": [ "Quotes are not the only characters that can be escaped inside a string. Here is a table of common escape sequences:", "
CodeOutput
\\'single quote
\\\"double quote
\\\\backslash
\\nnew line
\\rcarriage return
\\ttab
\\bbackspace
\\fform feed
", - "Note that the backslash itself must be escaped in order to display as a backslash.", + "Note that the backslash itself must be escaped in order to display as a backslash.", "

Instructions

", "Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr" ], @@ -4167,14 +4167,17 @@ "You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unqiue id number and which has several properties. Not all albums have complete information.", "Write a function which takes an id, a property (prop), and a value.", "For the given id in collection:", - "If the property is \"tracks\", push the value onto the end of the tracks array.", "If value is non-blank (value !== \"\"), then update or set the value for the prop.", + "If the prop is \"tracks\" and value is non-blank, push the value onto the end of the tracks array.", "If value is blank, delete that prop.", "Always return the entire collection object." ], "releasedOn": "11/27/2015", "tests": [ - "assert(1===1, 'message: message here');" + "collection = collectionCopy; assert(update(5439, \"artist\", \"ABBA\")[5439][\"artist\"] === \"ABBA\", 'message: After update(5439, \"artist\", \"ABBA\"), artist should be \"ABBA\"');", + "update(2548, \"artist\", \"\"); assert(!collection[2548].hasOwnProperty(\"artist\"), 'message: After update(2548, \"artist\", \"\"), artist should not be set');", + "assert(update(1245, \"tracks\", \"Addicted to Love\")[1245][\"tracks\"].length === 1, 'message: After update(1245, \"tracks\", \"Addicted to Love\"), tracks should have a length of 1');", + "update(2548, \"tracks\", \"\"); assert(!collection[2548].hasOwnProperty(\"tracks\"), 'message: After update(2548, \"tracks\", \"\"), tracks should not be set');" ], "challengeSeed": [ "var collection = {", @@ -4202,6 +4205,8 @@ " 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 update(id, prop, value) {", @@ -4215,13 +4220,54 @@ "" ], "tail": [ - "" + "(function(x) { return \"collection = \\n\" + JSON.stringify(x, '\\n', 2); })(collection);" ], "solutions": [ - "" + "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\"", + " }", + "};", + "// Keep a copy of the collection for tests", + "var collectionCopy = JSON.parse(JSON.stringify(collection));", + "", + "// Only change code below this line", + "function update(id, prop, value) {", + " if(value !== \"\") {", + " if(prop === \"tracks\") {", + " collection[id][prop].push(value);", + " } else {", + " collection[id][prop] = value;", + " }", + " } else {", + " delete collection[id][prop];", + " }", + "", + " return collection;", + "}" ], - "type": "waypoint", - "challengeType": "1", + "type": "bonfire", + "challengeType": "5", "nameCn": "", "nameFr": "", "nameRu": "", @@ -5446,4 +5492,4 @@ "challengeType": "0" } ] -} +} \ No newline at end of file