Merge branch 'bugron-basic_js_fix-2' of https://github.com/bugron/FreeCodeCamp into bugron-bugron-basic_js_fix-2

Conflicts:
	seed/challenges/basic-javascript.json
pull/2800/merge
Quincy Larson 2015-09-13 20:59:54 -07:00
commit 9bdbb59b67
1 changed files with 31 additions and 31 deletions

View File

@ -421,17 +421,17 @@
"difficulty": "9.9816",
"description": [
"With JavaScript <code>array</code> variables, we can store several pieces of data in one place.",
"You start an array declaration with an opening bracket, end it with a closing bracket, and put a comma between each entry, like this: <code>var sandwich = [\"peanut butter\", \"jelly\", \"bread\"]</code>.",
"You start an array declaration with an opening square bracket, end it with a closing square bracket, and put a comma between each entry, like this: <code>var sandwich = [\"peanut butter\", \"jelly\", \"bread\"]</code>.",
"Now let's create a new array called <code>myArray</code> that contains both a <code>string</code> and a <code>number</code> (in that order).",
"Refer to the comments if you get stuck."
],
"tests": [
"assert(typeof(myArray) == 'object', 'myArray should be an array');",
"assert(typeof(myArray[0]) !== 'undefined' && typeof(myArray[0]) == 'string', 'The first item in myArray should be a string');",
"assert(typeof(myArray[1]) !== 'undefined' && typeof(myArray[1]) == 'number', 'The second item in myArray should be a number');"
"assert(typeof(myArray) == 'object', '<code>myArray</code> should be an <code>array</code>.');",
"assert(typeof(myArray[0]) !== 'undefined' && typeof(myArray[0]) == 'string', 'The first item in <code>myArray</code> should be a <code>string</code>.');",
"assert(typeof(myArray[1]) !== 'undefined' && typeof(myArray[1]) == 'number', 'The second item in <code>myArray</code> should be a <code>number</code>.');"
],
"challengeSeed": [
"//var array = [\"John\", 23];",
"// var array = [\"John\", 23];",
"",
"// Only change code below this line.",
"",
@ -484,11 +484,11 @@
"Create a variable called <code>myData</code> and set it to equal the first value of <code>myArray</code>."
],
"tests":[
"assert((function(){if(typeof(myArray) != 'undefined' && typeof(myData) != 'undefined' && myArray[0] == myData){return true;}else{return false;}})(), 'The variable <code>myData</code> should equal the first value of myArray');"
"assert((function(){if(typeof(myArray) != 'undefined' && typeof(myData) != 'undefined' && myArray[0] == myData){return true;}else{return false;}})(), 'The variable <code>myData</code> should equal the first value of <code>myArray</code>.');"
],
"challengeSeed":[
"//var ourArray = [1,2,3];",
"//var ourData = ourArray[0]; // equals 1",
"// var ourArray = [1,2,3];",
"// var ourData = ourArray[0]; // equals 1",
"",
"var myArray = [1,2,3];",
"// Only change code below this line.",
@ -514,8 +514,8 @@
"Now modify the data stored at index 0 of <code>myArray</code> to the value of 3."
],
"tests":[
"assert((function(){if(typeof(myArray) != 'undefined' && myArray[0] == 3 && myArray[1] == 2 && myArray[2] == 3){return true;}else{return false;}})(), 'myArray should now be [3,2,3]');",
"assert((function(){if(editor.getValue().match(/myArray\\[0\\]\\s?=\\s?/g)){return true;}else{return false;}})(), 'You should be using correct index to modify the value in myArray');"
"assert((function(){if(typeof(myArray) != 'undefined' && myArray[0] == 3 && myArray[1] == 2 && myArray[2] == 3){return true;}else{return false;}})(), '<code>myArray</code> should now be [3,2,3].');",
"assert((function(){if(editor.getValue().match(/myArray\\[0\\]\\s?=\\s?/g)){return true;}else{return false;}})(), 'You should be using correct index to modify the value in <code>myArray</code>.');"
],
"challengeSeed":[
"var ourArray = [1,2,3];",
@ -541,18 +541,18 @@
"Another way to change the data in an array is with the <code>.pop()</code> function.",
"<code>.pop()</code>is used to \"pop\" a value off of the end of an array. We can retrieve this value by performing <code>pop()</code> in a variable declaration.",
"Any type of variable can be \"popped\" off of an array.",
"Use the <code>.pop()</code> function to remove the last item from myArray."
"Use the <code>.pop()</code> function to remove the last item from <code>myArray</code>."
],
"tests": [
"assert((function(d){if(d[0] == 'John' && d[1] == 23 && d[2] == undefined){return true;}else{return false;}})(myArray), 'myArray should only have the first two values left([\"John\", 23])');",
"assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return true;}else{return false;}})(removed), 'myArray should only have the first two values left([\"cat\"], 2)');"
"assert((function(d){if(d[0] == 'John' && d[1] == 23 && d[2] == undefined){return true;}else{return false;}})(myArray), '<code>myArray</code> should only have the first two values left([\"John\", 23]).');",
"assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return true;}else{return false;}})(removed), '<code>removed</code> should only have the first two values left([\"cat\"], 2).');"
],
"challengeSeed": [
"//var numbers = [1,2,3];",
"//console.log(numbers); // logs [1,2,3]",
"//var removed = numbers.pop();",
"//console.log(numbers); // logs [1,2]",
"//console.log(removed); // logs 3",
"// var numbers = [1,2,3];",
"// console.log(numbers); // logs [1,2,3]",
"// var removed = numbers.pop();",
"// console.log(numbers); // logs [1,2]",
"// console.log(removed); // logs 3",
"",
"var myArray = [\"John\", 23, [\"cat\", 2]];",
"// Only change code below this line.",
@ -573,20 +573,20 @@
"difficulty": "9.9818",
"description": [
"Not only can you <code>pop()</code> data off of the end of an array, you can also <code>push()</code> data onto the end of an array.",
"Take the myArray array and <code>push()</code> this value to the end of it: <code>[\"dog\", 3]</code>."
"Take the <code>myArray</code> array and <code>push()</code> this value to the end of it: <code>[\"dog\", 3]</code>."
],
"tests": [
"assert((function(d){if(d[2] != undefined && d[0] == 'John' && d[1] == 23 && d[2][0] == 'dog' && d[2][1] == 3 && d[2].length == 2){return true;}else{return false;}})(myArray), 'myArray should only have the first two values left([\"John\", 23, [\"dog\", 3]])');"
"assert((function(d){if(d[2] != undefined && d[0] == 'John' && d[1] == 23 && d[2][0] == 'dog' && d[2][1] == 3 && d[2].length == 2){return true;}else{return false;}})(myArray), '<code>myArray</code> should only have the first two values left([\"John\", 23, [\"dog\", 3]]).');"
],
"challengeSeed": [
"var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];",
"ourArray.pop();",
"ourArray.push([\"happy\", \"joy\"]);",
"// ourArray now equals [\"Stimpson\", \"J\", [\"happy\", \"joy\"]]",
"// ourArray now equals [\"Stimpson\", \"J\", [\"happy\", \"joy\"]].",
"",
"var myArray = [\"John\", 23, [\"cat\", 2]];",
"myArray.pop();",
"//Add a [\"dog\", 3] to the end of myArray using push()",
"// Add a [\"dog\", 3] to the end of myArray using push().",
"// Only change code below this line.",
"",
"",
@ -604,21 +604,21 @@
"difficulty": "9.9817",
"description": [
"<code>pop()</code> always removes the last element of an array. What if you want to remove the first? That's where <code>.shift()</code> comes in.",
"Take the myArray array and <code>shift()</code> the first value off of it. Set <code>myRemoved</code> to the first value of <code>myArray</code> using <code>shift()</code>."
"Take the <code>myArray</code> array and <code>shift()</code> the first value off of it. Set <code>myRemoved</code> to the first value of <code>myArray</code> using <code>shift()</code>."
],
"tests": [
"assert((function(d){if(d[0] == 23 && d[1][0] == 'dog' && d[1][1] == 3 && d[2] == undefined){return true;}else{return false;}})(myArray), 'myArray should only have the last two values left([23, [\"dog\", 3]])');",
"assert((function(d){if(d === 'John' && typeof(myRemoved) === 'string'){return true;}else{return false;}})(myRemoved), 'myRemoved should contain \"John\"');"
"assert((function(d){if(d[0] == 23 && d[1][0] == 'dog' && d[1][1] == 3 && d[2] == undefined){return true;}else{return false;}})(myArray), '<code>myArray</code> should only have the last two values left([23, [\"dog\", 3]]).');",
"assert((function(d){if(d === 'John' && typeof(myRemoved) === 'string'){return true;}else{return false;}})(myRemoved), '<code>myRemoved</code> should contain <code>\"John\"</code>.');"
],
"challengeSeed": [
"var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];",
"ourRemoved = ourArray.shift();",
"// ourArray now equals [\"J\", [\"cat\"]]",
"// ourArray now equals [\"J\", [\"cat\"]].",
"",
"var myArray = [\"John\", 23, [\"dog\", 3]];",
"// Only change code below this line.",
"",
"var myRemoved = myArray; // This should be [\"John\"] and myArray should now be [23, [\"dog\", 3]]",
"var myRemoved = myArray; // This should be [\"John\"] and myArray should now be [23, [\"dog\", 3]].",
"",
"// Only change code above this line.",
"",
@ -634,8 +634,8 @@
"title": "Manipulate Arrays With unshift()",
"difficulty": "9.9818",
"description": [
"Now that we've learned how to <code>shift</code>things from the start of the array, we need to learn how to <code>unshift</code>stuff back to the start",
"Let's take the code we had last time and <code>unshift</code>this value to the start: <code>\"Paul\" </code>"
"Now that we've learned how to <code>shift</code>things from the start of the array, we need to learn how to <code>unshift</code>stuff back to the start.",
"Let's take the code we had last time and <code>unshift</code>this value to the start: <code>\"Paul\"</code>."
],
"tests": [
"assert((function(d){if(typeof(d[0]) === \"string\" && d[0].toLowerCase() == 'paul' && d[1] == 23 && d[2][0] != undefined && d[2][0] == 'dog' && d[2][1] != undefined && d[2][1] == 3){return true;}else{return false;}})(myArray), '<code>myArray</code> should now have [\"Paul\", 23, [\"dog\", 3]]).');"
@ -643,13 +643,13 @@
"challengeSeed": [
"var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];",
"ourArray.shift();",
"ourArray.unshift(\"happy\");",
"// ourArray now equals [\"happy\", \"J\", [\"cat\"]]",
"ourArray.unshift(\"happy\");",
"",
"var myArray = [\"John\", 23, [\"dog\", 3]];",
"myArray.shift();",
"",
"// Add \"Paul\" to the start of myArray",
"// Add \"Paul\" to the start of myArray.",
"// Only change code below this line.",
"",
"",