From bcd5ca388ceb982bf4a79432eb7200c9d9223249 Mon Sep 17 00:00:00 2001 From: Abhisek Pattnaik Date: Fri, 8 Jul 2016 04:59:10 +0530 Subject: [PATCH] :checkered_flag: Improve/Fix Record Collection Challenge docs(challenge): :book: :checkered_flag: improve instruction wording - improve wording of instruction - fix invalid tag style(challenge): :dancer: :checkered_flag: Fix whitespace in challenge seed - Fix whitespace in challenge seed - Prepend semicolon in tail code so that challenge works even if challenge seed doesn't end with a semicolon. refactor(challenge): :wrench: :checkered_flag: Improved readability of solution --- .../basic-javascript.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 6b81a00965..3f8638d859 100644 --- a/seed/challenges/01-front-end-development-certification/basic-javascript.json +++ b/seed/challenges/01-front-end-development-certification/basic-javascript.json @@ -2052,7 +2052,7 @@ "

Instructions

", "
  1. Create a function called reusableFunction which prints \"Hi World\" to the dev console.
  2. Call the function.
" ], - "head": [ + "head": [ "var logOutput = \"\";", "var originalConsole = console", "function capture() {", @@ -4513,15 +4513,15 @@ "description": [ "You are given a JSON object representing a part of your musical album collection. Each album has several properties and a unique id number as its key. Not all albums have complete information.", "Write a function which takes an album's id (like 2548), a property prop (like \"artist\" or \"tracks\"), and a value (like \"Addicted to Love\") to modify the data in this collection.", - "If prop isn't \"tracks\" and value isn't blank, update or set the value for that record album's property.", + "If prop isn't \"tracks\" and value isn't empty (\"\"), update or set the value for that record album's property.", "Your function must always return the entire collection object.", "There are several rules for handling incomplete data:", "If prop is \"tracks\" but the album doesn't have a \"tracks\" property, create an empty array before adding the new value to the album's corresponding property.", - "If prop is \"tracks\" and value isn't blank, push the value onto the end of the album's existing tracks array.", - "If value is blank, delete that property from the album.", + "If prop is \"tracks\" and value isn't empty (\"\"), push the value onto the end of the album's existing tracks array.", + "If value is empty (\"\"), delete the given prop property from the album.", "Hints
Use bracket notation when accessing object properties with variables.", "Push is an array method you can read about on Mozilla Developer Network.", - "You may refer back to Manipulating Complex ObjectsIntroducing JavaScript Object Notation (JSON) for a refresher." + "You may refer back to Manipulating Complex Objects Introducing JavaScript Object Notation (JSON) for a refresher." ], "releasedOn": "January 1, 2016", "challengeSeed": [ @@ -4556,8 +4556,8 @@ "", "// Only change code below this line", "function updateRecords(id, prop, value) {", - "", - "", + " ", + " ", " return collection;", "}", "", @@ -4566,10 +4566,10 @@ "" ], "tail": [ - "(function(x) { return \"collection = \\n\" + JSON.stringify(x, '\\n', 2); })(collection);" + ";(function(x) { return \"collection = \\n\" + JSON.stringify(x, '\\n', 2); })(collection);" ], "solutions": [ - "var collection = {\n 2548: {\n album: \"Slippery When Wet\",\n artist: \"Bon Jovi\",\n tracks: [ \n \"Let It Rock\", \n \"You Give Love a Bad Name\" \n ]\n },\n 2468: {\n album: \"1999\",\n artist: \"Prince\",\n tracks: [ \n \"1999\", \n \"Little Red Corvette\" \n ]\n },\n 1245: {\n artist: \"Robert Palmer\",\n tracks: [ ]\n },\n 5439: {\n album: \"ABBA Gold\"\n }\n};\n// Keep a copy of the collection for tests\nvar collectionCopy = JSON.parse(JSON.stringify(collection));\n\n// Only change code below this line\nfunction updateRecords(id, prop, value) {\n if(value !== \"\") {\n if(prop === \"tracks\") {\n collection[id][prop]= collection[id][prop] || [];\n collection[id][prop].push(value);\n } else {\n collection[id][prop] = value;\n }\n } else {\n delete collection[id][prop];\n }\n\n return collection;\n}" + "var collection = {\n 2548: {\n album: \"Slippery When Wet\",\n artist: \"Bon Jovi\",\n tracks: [ \n \"Let It Rock\", \n \"You Give Love a Bad Name\" \n ]\n },\n 2468: {\n album: \"1999\",\n artist: \"Prince\",\n tracks: [ \n \"1999\", \n \"Little Red Corvette\" \n ]\n },\n 1245: {\n artist: \"Robert Palmer\",\n tracks: [ ]\n },\n 5439: {\n album: \"ABBA Gold\"\n }\n};\n// Keep a copy of the collection for tests\nvar collectionCopy = JSON.parse(JSON.stringify(collection));\n\n// Only change code below this line\nfunction updateRecords(id, prop, value) {\n if(value === \"\") delete collection[id][prop];\n else if(prop === \"tracks\") {\n collection[id][prop] = collection[id][prop] || [];\n collection[id][prop].push(value);\n } else {\n collection[id][prop] = value;\n }\n \n return collection;\n}" ], "tests": [ "collection = collectionCopy; assert(updateRecords(5439, \"artist\", \"ABBA\")[5439][\"artist\"] === \"ABBA\", 'message: After updateRecords(5439, \"artist\", \"ABBA\"), artist should be \"ABBA\"');",