Merge pull request #9096 from LindsayBrown81/fix/disambiguate-property-meaning

fix/disambiguate-property-meaning, make JSON valid in basic-javascript.json
This commit is contained in:
Jonathan
2016-06-18 19:28:53 +01:00
committed by GitHub

View File

@ -4329,6 +4329,13 @@
"<blockquote>var ourMusic = [<br> {<br> \"artist\": \"Daft Punk\",<br> \"title\": \"Homework\",<br> \"release_year\": 1997,<br> \"formats\": [ <br> \"CD\", <br> \"Cassette\", <br> \"LP\" ],<br> \"gold\": true<br> }<br>];</blockquote>",
"This is an array of objects and the object has various pieces of <dfn>metadata</dfn> about an album. It also has a nested <code>formats</code> array. Additional album records could be added to the top level array.",
"<strong>Note</strong><br>You will need a comma in between objects with more than one object in the array.",
"JavaScript Object Notation or <code>JSON</code> is a data interchange format used to store data (source: <a href=\"http://json.org/\">json.org</a>).",
"A property is the part of an object that associates a key (either a String value or a Symbol value) and a value (source: <a href=\"http://www.ecma-international.org/ecma-262/6.0/#sec-property\">ecma-international.org/ecma-262/6.0/#sec-property</a>). So, a property consists of a key - value pair. (source: <a href=\"http://spacetelescope.github.io/understanding-json-schema/reference/object.html#properties\">spacetelescope.github.io/understanding-json-schema/reference/object.html#properties</a>). Property keys (also known as names) should be in quotation marks.",
"Like JavaScript Objects, JSON is flexible because it is heterogeneous, meaning it permits <dfn>Data Structures</dfn> with arbitrary combinations of <dfn>strings</dfn>, <dfn>booleans</dfn>, <dfn>numbers</dfn>, <dfn>arrays</dfn>, and <dfn>objects</dfn>.",
"Here is an example of a JSON object:",
"<blockquote>var ourMusic = [<br> {<br> \"artist\": \"Daft Punk\",<br> \"title\": \"Homework\",<br> \"release_year\": 1997,<br> \"formats\": [ <br> \"CD\", <br> \"Cassette\", <br> \"LP\" ],<br> \"gold\": true<br> }<br>];</blockquote>",
"This is an array of objects and the object has various pieces of <dfn>metadata</dfn> about an album. It also has a nested <code>formats</code> array. Additional album records could be added to the top level array.",
"<strong>Note</strong><br>You will need to place a comma in between objects in JSON unless there is only one object in the array or containing object.",
"<h4>Instructions</h4>",
"Add a new album to the <code>myMusic</code> object. Add <code>artist</code> and <code>title</code> strings, <code>release_year</code> number, and a <code>formats</code> 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 <code>id</code>, a property (<code>prop</code>), and a <code>value</code>.",
"For the given <code>id</code> in <code>collection</code>:",
"If <code>value</code> is non-blank (<code>value !== \"\"</code>) and <code>prop</code> is not <code>\"tracks\"</code> then update or set the <code>value</code> for the <code>prop</code>.",
"If the <code>prop</code> is <code>\"tracks\"</code> and <code>value</code> is non-blank, push the <code>value</code> onto the end of the <code>tracks</code> array.",
"If <code>\"tracks\"</code> is non-existent before you update it, create an empty array before pushing a track to it.",
"If <code>prop</code> does not contain the key <code>\"tracks\"</code>, then update or set the <code>value</code> for that incomplete <code>prop</code>.",
"If <code>prop</code> does not contain the key <code>\"tracks\"</code> before you update it, create an empty array before pushing a track to it.",
"If <code>prop</code> does contain the key <code>\"tracks\"</code> and its <code>value</code> is non-blank, then push the <code>value</code> onto the end of its existing <code>tracks</code> array.",
"If <code>value</code> is blank, delete that <code>prop</code>.",
"Always return the entire collection object.",
"<strong>Note</strong><br>Don't forget to use <code>bracket notation</code> when <a href=\"accessing-objects-properties-with-variables\" target=\"_blank\">accessing object properties with variables</a>."
"<strong>Hints</strong><br>Use <code>bracket notation</code> when <a href=\"accessing-objects-properties-with-variables\" target=\"_blank\">accessing object properties with variables</a>.",
"Push is an array method you can read about on <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push\">Mozilla Developer Network</a>.",
"You may refer back to <a href=\"https://www.freecodecamp.com/challenges/introducing-javascript-object-notation-json\">Introducing JavaScript Object Notation (JSON)</a> 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) {",