Merge pull request #5567 from abhisekp/fix/basic-javascript-updates

Basic Javascript Waypoint fixes
pull/5582/head
Logan Tegman 2015-12-30 11:30:24 -08:00
commit 85477f5743
1 changed files with 17 additions and 17 deletions

View File

@ -99,7 +99,7 @@
"id": "56533eb9ac21ba0edf2244a8",
"title": "Storing Values with the Equal Operator",
"description": [
"In Javascript, you can store a value in a variable with the <dfn>assignment</dfn> or <code>equal</code> (<code>=</code>) operator.",
"In JavaScript, you can store a value in a variable with the <dfn>assignment</dfn> or <code>equal</code> (<code>=</code>) operator.",
"<code>myVariable = 5;</code>",
"Assigns the <code>Number</code> value <code>5</code> to <code>myVariable</code>.",
"Assignment always goes from right to left. Everything to the right of the <code>=</code> operator is resolved before the value is assigned to the variable to the left of the operator.",
@ -107,7 +107,7 @@
"<code>myNum = myVar;</code>",
"Assigns <code>5</code> to <code>myVar</code> and then resolves <code>myVar</code> to <code>5</code> again and assigns it to <code>myNum</code>.",
"<h4>Instructions</h4>",
"Assign the value 7 to variable <code>a</code>",
"Assign the value <code>7</code> to variable <code>a</code>",
"Assign the contents of <code>a</code> to variable <code>b</code>."
],
"releasedOn": "January 1, 2016",
@ -1853,7 +1853,7 @@
"id": "56533eb9ac21ba0edf2244be",
"title": "Global Scope and Functions",
"description": [
"In Javascript, <dfn>scope</dfn> refers to the visibility of variables. Variables which are defined outside of a function block have <dfn>Global</dfn> scope. This means, they can be seen everywhere in your JavaScript code.",
"In JavaScript, <dfn>scope</dfn> refers to the visibility of variables. Variables which are defined outside of a function block have <dfn>Global</dfn> scope. This means, they can be seen everywhere in your JavaScript code.",
"Variables which are used without the <code>var</code> keyword are automatically created in the <code>global</code> scope. This can create unintended consequences elsewhere in your code or when running a function again. You should always declare your variables with <code>var</code>.",
"<h4>Instructions</h4>",
"Declare a <code>global</code> variable <code>myGlobal</code> outside of any function. Initialize it to have a value of <code>10</code> ",
@ -1911,7 +1911,7 @@
"assert(myGlobal === 10, 'message: <code>myGlobal</code> should have a value of <code>10</code>');",
"assert(/var\\s+myGlobal/.test(code), 'message: <code>myGlobal</code> should be declared using the <code>var</code> keyword');",
"assert(typeof oopsGlobal != \"undefined\" && oopsGlobal === 5, 'message: <code>oopsGlobal</code> should have a value of <code>5</code>');",
"assert(!/var\\s+oopsGlobal/.test(code), 'message: Do not decalre <code>oopsGlobal</code> using the <code>var</code> keyword');"
"assert(!/var\\s+oopsGlobal/.test(code), 'message: Do not declare <code>oopsGlobal</code> using the <code>var</code> keyword');"
],
"type": "waypoint",
"challengeType": "1",
@ -3350,7 +3350,7 @@
"id": "56533eb9ac21ba0edf2244c9",
"title": "Accessing Objects Properties with Variables",
"description": [
"Another use of bracket notation on objects is to use a variable to access a property. This can be very useful for iterating through lists of object properties or for doing lookup.",
"Another use of bracket notation on objects is to use a variable to access a property. This can be very useful for iterating through lists of the object properties or for doing the lookup.",
"Here is an example of using a variable to access a property:",
"<blockquote>var someProp = \"propName\";<br>var myObj = {<br> propName: \"Some Value\"<br >}<br>myObj[someProp]; // \"Some Value\"</blockquote>",
"Note that we do <em>not</em> use quotes around the variable name when using it to access the property because we are using the <em>value</em> of the variable, not the <em>name</em>",
@ -3620,7 +3620,7 @@
"",
"function checkObj(checkProp) {",
" // Your Code Here",
"",
" ",
" return \"Change Me!\";",
"}",
"",
@ -3645,10 +3645,10 @@
"id": "56533eb9ac21ba0edf2244cb",
"title": "Introducing JavaScript Object Notation (JSON)",
"description": [
"JavaScript Object Notation or <code>JSON</code> uses the format of Javascript Objects to store data. JSON is flexible becuase it allows for data structures with arbitrary combinations of <dfn>strings</dfn>, <dfn>numbers</dfn>, <dfn>booleans</dfn>, <dfn>arrays</dfn>, and <dfn>objects</dfn>. ",
"JavaScript Object Notation or <code>JSON</code> uses the format of JavaScript Objects to store data. JSON is flexible because it allows for <dfn>Data Structures</dfn> with arbitrary combinations of <dfn>strings</dfn>, <dfn>numbers</dfn>, <dfn>booleans</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 array of formats. Additional album records could be added to the top level array.",
"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.",
"<h4>Instructions</h4>",
"Add a new album to the <code>myMusic</code> JSON object. Add <code>artist</code> and <code>title</code> strings, <code>release_year</code> year, and a <code>formats</code> array of strings."
],
@ -4057,17 +4057,17 @@
"title": "Nesting For Loops",
"description": [
"If you have a multi-dimensional array, you can use the same logic as the prior waypoint to loop through both the array and any sub-arrays. Here is an example:",
"<blockquote>var arr = [<br> [1,2], [3,4], [5,6]<br>];<br>for (var i=0; i &lt; arr.length; i++) {<br> for (var j=0; k &lt; arr[i].length; j++) {<br> console.log(arr[i][j]);<br> }<br>}</blockquote>",
"This outputs each sub-element in <code>arr</code> one at a time. Note that for the inner loop we are checking the <code>.length</code> of <code>arr[i]</code>, since <code>arr[i]</code> is itself an array.",
"<blockquote>var arr = [<br> [1,2], [3,4], [5,6]<br>];<br>for (var i=0; i &lt; arr.length; i++) {<br> for (var j=0; j &lt; arr[i].length; j++) {<br> console.log(arr[i][j]);<br> }<br>}</blockquote>",
"This outputs each sub-element in <code>arr</code> one at a time. Note that for the inner loop, we are checking the <code>.length</code> of <code>arr[i]</code>, since <code>arr[i]</code> is itself an array.",
"<h4>Instructions</h4>",
"Modify function <code>multiplyAll</code> so that it multiplies <code>product</code> by each number in the subarrays of <code>arr</code>"
"Modify function <code>multiplyAll</code> so that it multiplies the <code>product</code> variable by each number in the sub-arrays of <code>arr</code>"
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
"function multiplyAll(arr) {",
" var product = 1;",
" // Only change code below this line",
"",
" ",
" // Only change code above this line",
" return product;",
"}",
@ -4142,9 +4142,9 @@
" var codeArr = encodedStr.split(\"\"); // String to Array",
" var decodedArr = []; // Your Result goes here",
" // Only change code below this line",
"",
"",
"",
" ",
" ",
" ",
" // Only change code above this line",
" return decodedArr.join(\"\"); // Array to String",
"}",