From 3fa86377f87c98cb5a3ea3bae84daee3424cf58c Mon Sep 17 00:00:00 2001 From: LindsayBrown81 Date: Sat, 11 Jun 2016 19:14:43 -0400 Subject: [PATCH] fix/disambiguate-property-meaning, make JSON valid in basic-javascript.json #9096 Lines 4322-4323: made links HTML tags instead of markdown in the definitions I added for JSON and property. Line 4324: added booleans and numbers back into the Data Structures and overall reduced number of words used in explanations. Lines 4338 and 4343: removed quotes from integer value and boolean value because the JSON is valid without them. Line 4502: specified what part of property the ID number is to reinforce that a property consists of a key (or name) and a value. Lines 4505-4508: reworded the conditions to be more consistent and comprehensible, changed their order. Line 4510: retitled Note to Hints and added two more hints. Line 4543: changed from my first PR's suggestion of var collectionCopy = JSON.stringify(collection) back to var collectionCopy = JSON.parse(JSON.stringify(collection)). --- .../basic-javascript.json | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 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 b255a114ec..4cce7dc64d 100644 --- a/seed/challenges/01-front-end-development-certification/basic-javascript.json +++ b/seed/challenges/01-front-end-development-certification/basic-javascript.json @@ -4329,6 +4329,13 @@ "
var ourMusic = [
{
\"artist\": \"Daft Punk\",
\"title\": \"Homework\",
\"release_year\": 1997,
\"formats\": [
\"CD\",
\"Cassette\",
\"LP\" ],
\"gold\": true
}
];
", "This is an array of objects and the object has various pieces of metadata about an album. It also has a nested formats array. Additional album records could be added to the top level array.", "Note
You will need a comma in between objects with more than one object in the array.", + "JavaScript Object Notation or JSON is a data interchange format used to store data (source: json.org).", + "A property is the part of an object that associates a key (either a String value or a Symbol value) and a value (source: ecma-international.org/ecma-262/6.0/#sec-property). So, a property consists of a key - value pair. (source: spacetelescope.github.io/understanding-json-schema/reference/object.html#properties). Property keys (also known as names) should be in quotation marks.", + "Like JavaScript Objects, JSON is flexible because it is heterogeneous, meaning it permits Data Structures with arbitrary combinations of strings, booleans, numbers, arrays, and objects.", + "Here is an example of a JSON object:", + "
var ourMusic = [
{
\"artist\": \"Daft Punk\",
\"title\": \"Homework\",
\"release_year\": 1997,
\"formats\": [
\"CD\",
\"Cassette\",
\"LP\" ],
\"gold\": true
}
];
", + "This is an array of objects and the object has various pieces of metadata about an album. It also has a nested formats array. Additional album records could be added to the top level array.", + "Note
You will need to place a comma in between objects in JSON unless there is only one object in the array or containing object.", "

Instructions

", "Add a new album to the myMusic object. Add artist and title strings, release_year number, and a formats array of strings." ], @@ -4503,45 +4510,48 @@ "title": "Record Collection", "description": [ "You are given an object representing (a small part of) your record collection. Each album is identified by a unique id number and has several properties. Not all albums have complete information.", + "You are given a JSON object representing (a small part of) your record collection. Each album is identified by a unique id number (its key) and 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 value is non-blank (value !== \"\") and prop is not \"tracks\" 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 \"tracks\" is non-existent before you update it, create an empty array before pushing a track to it.", + "If prop does not contain the key \"tracks\", then update or set the value for that incomplete prop.", + "If prop does not contain the key \"tracks\" before you update it, create an empty array before pushing a track to it.", + "If prop does contain the key \"tracks\" and its value is non-blank, then push the value onto the end of its existing tracks array.", "If value is blank, delete that prop.", "Always return the entire collection object.", - "Note
Don't forget to use bracket notation when accessing object properties with variables." + "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 Introducing JavaScript Object Notation (JSON) for a refresher." ], "releasedOn": "January 1, 2016", "challengeSeed": [ "// Setup", "var collection = {", - " 2548: {", - " album: \"Slippery When Wet\",", - " artist: \"Bon Jovi\",", + " \"2548\": {", + " \"album\": \"Slippery When Wet\",", + " \"artist\": \"Bon Jovi\",", " tracks: [ ", " \"Let It Rock\", ", " \"You Give Love a Bad Name\" ", " ]", " },", - " 2468: {", - " album: \"1999\",", - " artist: \"Prince\",", - " tracks: [ ", + " \"2468\": {", + " \"album\": \"1999\",", + " \"artist\": \"Prince\",", + " \"tracks\": [ ", " \"1999\", ", " \"Little Red Corvette\" ", " ]", " },", - " 1245: {", - " artist: \"Robert Palmer\",", - " tracks: [ ]", + " \"1245\": {", + " \"artist\": \"Robert Palmer\",", + " \"tracks\": [ ]", " },", - " 5439: {", - " album: \"ABBA Gold\"", + " \"5439\": {", + " \"album\": \"ABBA Gold\"", " }", "};", "// Keep a copy of the collection for tests", - "var collectionCopy = JSON.parse(JSON.stringify(collection));", + "var collectionCopy = JSON.parse(stringify(collection));", "", "// Only change code below this line", "function updateRecords(id, prop, value) {",