Reformat challenge descriptions and titles

This commit is contained in:
robertweber95
2017-02-17 22:07:22 -05:00
parent 930ef4a315
commit c27c5eb6df

View File

@ -407,29 +407,27 @@
}, },
{ {
"id": "587d7b89367417b2b2512b4a", "id": "587d7b89367417b2b2512b4a",
"title": "Nested Object Destructuring", "title": "Use Destructuring Assignment with Nested Objects",
"description": [ "description": [
"We can similarly destructure nested objects", "We can similarly destructure <em>nested</em> objects into variables.",
"Consider the following code:", "Consider the following code:",
"<code>const a = { start: { x: 5, y: 6}, end: { x: 6, y: -9 }};</code>", "<blockquote>const a = {<br> start: { x: 5, y: 6},<br> end: { x: 6, y: -9 }<br>};<br>const { start : { x: startX, y: startY }} = a;<br>console.log(startX, startY); // 5, 6</blockquote>",
"<code>const { start : { x: startX, y: startY }} = a;</code>", "In the example above, the variable <code>start</code> is assigned the value of <code>a.start</code>, which is also an object.",
"<code>console.log(startX, startY); // 5, 6</code>", "<hr>",
"It pulls from the first nested object. Rest of the syntax is as it was for simple object destructuring.", "Use destructuring assignment to obtain <code>max</code> of <code>forecast.tomorrow</code> and assign it to <code>maxOfTomorrow</code>."
"Instructions.",
"Use destructuring to obtain the max of tomorrow, which should be same as forecast.tomorrow.max"
], ],
"challengeSeed": [ "challengeSeed": [
"const forecast = {", "const forecast = {",
" today: { min: 72, max: 83},", " today: { min: 72, max: 83 },",
" tomorrow: {min: 73.3, max: 84.6}", " tomorrow: { min: 73.3, max: 84.6 }",
"}", "};",
"/* Alter code below this line */", "// change code below this line",
"const max_of_tomorrow = undefined; // change this", "const maxOfTomorrow = undefined; // change this line",
"/* Alter code above this line */", "// change code above this line",
"console.log(max_of_tomorrow); // should be 84.6 destructuring" "console.log(maxOfTomorrow); // should be 84.6"
], ],
"tests": [ "tests": [
"// Test max_of_tomorrow to be 84.6", "// Test maxOfTomorrow to be 84.6",
"// Test destructuring was used" "// Test destructuring was used"
], ],
"type": "waypoint", "type": "waypoint",
@ -438,25 +436,24 @@
}, },
{ {
"id": "587d7b89367417b2b2512b4b", "id": "587d7b89367417b2b2512b4b",
"title": "Array Destructuring", "title": "Use Destructuring Assignment with Arrays",
"description": [ "description": [
"We can also destructure arrays as easily as objects.", "ES6 makes destructuring arrays as easy as destructuring objects.",
"One key difference between spread operator and array destructuring is that, spread operators unpack all contents of array.", "One key difference between the spread operator and array destructuring is that the spread operator unpacks all contents of an array into a comma-separated list. Consequently, you cannot pick and choose which elements or you want to assign to variables.",
"Consequently, you cannot pick and choose which element or set of elements you would want to assign to variables.",
"Destruring an array lets us do exactly that:", "Destruring an array lets us do exactly that:",
"<code>const [a, b] = [1, 2, 3, 4, 5, 7];</code>", "<blockquote>const [a, b] = [1, 2, 3, 4, 5, 6];<br>console.log(a, b); // 1, 2</blockquote>",
"<code>console.log(a, b); // 1, 2</code>", "The variable <code>a</code> is assigned the first value of the array, and <code>b</code> is assigned the second value of the array.",
"The variable a assumes first value, and b takes the second value from the array.", "We can also access the value at any index in an array with destructuring by using commas to reach the desired index:",
"You can also destructure in a way, that you can pick up values from any other array index position. You simply have to use commas (,).", "<blockquote>const [a, b,,, c] = [1, 2, 3, 4, 5, 6];<br>console.log(a, b, c); // 1, 2, 5 </blockquote>",
"Instructions.", "<hr>",
"Use destructuring to swap the variables a, b. Swapping is an operation, after which, a gets the value stored in b, and b receives the value stored in a" "Use destructuring assignment to swap the values of <code>a</code> and <code>b</code> so that <code>a</code> receives the value stored in <code>b</code>, and <code>b</code> receives the value stored in <code>a</code>."
], ],
"challengeSeed": [ "challengeSeed": [
"let a = 8, b = 6;", "let a = 8, b = 6;",
"/* Alter code below this line */", "// change code below this line",
"a = b;", "a = b;",
"b = a;", "b = a;",
"/* Alter code above this line */", "// change code above this line",
"console.log(a); // should be 6", "console.log(a); // should be 6",
"console.log(b); // should be 8" "console.log(b); // should be 8"
], ],
@ -471,23 +468,21 @@
}, },
{ {
"id": "587d7b8a367417b2b2512b4c", "id": "587d7b8a367417b2b2512b4c",
"title": "Array Destructuring with Rest Operator", "title": "Use Destructuring Assignment with the Rest Operator",
"description": [ "description": [
"There are situations with destructuring an array, where we might want to collect the rest of the elements into a separate array.", "In some situations involving array destructuring, we might want to collect the rest of the elements into a separate array.",
"Something similar to Array.prototype.slice(), as shown below:", "The result is similar to <code>Array.prototype.slice()</code>, as shown below:",
"<code>const [a, b, ...arr] = [1, 2, 3, 4, 5, 7];</code>", "<blockquote>const [a, b, ...arr] = [1, 2, 3, 4, 5, 7];<br>console.log(a, b); // 1, 2<br>console.log(arr); // [3, 4, 5, 7]</blockquote>",
"<code>console.log(a, b); // 1, 2</code>", "Variables <code>a</code> and <code>b</code> take the first and second values from the array. After that, because of rest operator's presence, <code>arr</code> gets rest of the values in the form of an array.",
"<code>console.log(arr); // [3, 4, 5, 7]</code>", "The rest element only works correctly as the last variable in the list. As in, you cannot use the rest operator to catch a subarray that leaves out last element of the original array.",
"The variable a assumes first value, and b takes the second value from the array. After that, because of rest operator's presence, arr gets rest of the values in the form of an array.", "<hr>",
"Note that the rest element has to be the last element in the array. As in, you cannot use rest operator to catch a subarray that leaves out last element of the original array.", "Use destructuring assignment with the rest operator to perform an effective <code>Array.prototype.slice()</code> so that <code>arr</code> is a sub-array of the original array <code>source</code> with the first two elements ommitted."
"Instructions.",
"Use destructuring with rest operator to perform an effective Array.prototype.slice() so that variable arr is sub-array of original array source, with first two elements ommitted."
], ],
"challengeSeed": [ "challengeSeed": [
"const source = [1,2,3,4,5,6,7,8,9,10];", "const source = [1,2,3,4,5,6,7,8,9,10];",
"/* Alter code below this line */", "// change code below this line",
"const arr = source ; // change this", "const arr = source; // change this",
"/* Alter code above this line */", "// change code below this line",
"console.log(arr); // should be [3,4,5,6,7,8,9,10]", "console.log(arr); // should be [3,4,5,6,7,8,9,10]",
"console.log(source); // should be [1,2,3,4,5,6,7,8,9,10];" "console.log(source); // should be [1,2,3,4,5,6,7,8,9,10];"
], ],
@ -503,33 +498,30 @@
}, },
{ {
"id": "587d7b8a367417b2b2512b4d", "id": "587d7b8a367417b2b2512b4d",
"title": "Destructuring Function Parameters", "title": "Use Destructuring Assignment on Function Parameters",
"description": [ "description": [
"In some cases, you can destructure the object in the function argument itself.", "In some cases, you can destructure the object in a function argument itself.",
"Consider the code below", "Consider the code below:",
"<code>const profileUpdate = (profileData) => {</code>", "<blockquote>const profileUpdate = (profileData) => {<br> const { name, age, nationality, location } = profileData;<br> // do something with these variables<br>}</blockquote>",
"<code> const { name, age, sex, nationality, location } = profileData;</code>", "This effectively destructures the object sent into the function. This can also be done in-place:",
"<code> // do something with these variables</code>", "<blockquote>const profileUpdate = ({ name, age, nationality, location }) => {<br> /* do something with these fields */<br>}</blockquote>",
"<code>}</code>", "This removes some extra lines and makes our code look neat.",
"This effectively destructure the object sent into the function. However, this can also be done in-place.", "This has the added benefit of not having to manipulate an entire object in a function; only the fields that are needed are copied inside the function.",
"const profileUpdate = ({ name, age, sex, nationality, location }) => {/* do something with these fields */}", "<hr>",
"This removes some extra linees and mainly a syntactic sugar.", "Use destructuring assignment within the argument to the function <code>half</code> to send only <code>max</code> and <code>min</code> inside the function."
"This also has the added benefit of not having to send an entire object into a function; rather only those fields are copied that are needed inside the function.",
"Instructions.",
"Use destructuring within function argument to send only the max and min inside the function"
], ],
"challengeSeed": [ "challengeSeed": [
"const stats = {", "const stats = {",
" max: 56.78,", " max: 56.78,",
" standard_deviation: 4.34,", " standard_deviation: 4.34,",
" median: 34.54,", " median: 34.54,",
" mode: 23.87,", " mode: 23.87,",
" min: -0.75,", " min: -0.75,",
" average: 35.85", " average: 35.85",
"}", "};",
"/* Alter code below this line */", "// change code below this line",
"const half = (stats) => ((stats.max + stats.min) / 2.0); // use function argument destructurung", "const half = (stats) => ((stats.max + stats.min) / 2.0); // use function argument destructurung",
"/* Alter code above this line */", "// change code above this line",
"console.log(stats); // should be object", "console.log(stats); // should be object",
"console.log(half(stats)); // should be 28.015" "console.log(half(stats)); // should be 28.015"
], ],