everything is ready except OOP

This commit is contained in:
Quincy Larson
2015-10-28 05:13:49 -07:00
parent 6a7d9e2878
commit 4820ae2e36
5 changed files with 110 additions and 80 deletions

View File

@ -65,7 +65,7 @@
"assert((function(){if(typeof(myName) !== \"undefined\" && typeof(myName) === \"string\" && myName.length > 0){return true;}else{return false;}})(), 'message: <code>myName</code> should be a string that contains at least one character in it.');" "assert((function(){if(typeof(myName) !== \"undefined\" && typeof(myName) === \"string\" && myName.length > 0){return true;}else{return false;}})(), 'message: <code>myName</code> should be a string that contains at least one character in it.');"
], ],
"challengeSeed": [ "challengeSeed": [
"// var ourName = \"Free Code Camp\";", "var ourName = \"Free Code Camp\";",
"", "",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
@ -87,9 +87,9 @@
"assert((function(){if(typeof(myLastName) !== \"undefined\" && typeof(myLastName) === \"string\" && myLastName.length > 0){return true;}else{return false;}})(), 'message: <code>myLastName</code> should be a string with at least one character in it.');" "assert((function(){if(typeof(myLastName) !== \"undefined\" && typeof(myLastName) === \"string\" && myLastName.length > 0){return true;}else{return false;}})(), 'message: <code>myLastName</code> should be a string with at least one character in it.');"
], ],
"challengeSeed": [ "challengeSeed": [
"// var name = \"Alan Turing\";", "var name = \"Alan Turing\";",
"// var firstName = \"Alan\";", "var firstName = \"Alan\";",
"// var lastName = \"Turing\";", "var lastName = \"Turing\";",
"", "",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
@ -230,7 +230,7 @@
"title": "Use Bracket Notation to Find the Nth-to-Last Character in a String", "title": "Use Bracket Notation to Find the Nth-to-Last Character in a String",
"description": [ "description": [
"In order to get the last letter of a string, you can subtract one from the string's length.", "In order to get the last letter of a string, you can subtract one from the string's length.",
"For example, you can get the value of the third-to-last letter of the <code>var firstName = \"Charles\"</code> string by using <code>firstName[firstName.length - 3]</code>.", "For example, you can get the value of the third-to-last letter of the <code>var firstName = \"Charles\"</code> string by using <code>firstName[firstName.length - 3]</code>",
"Use <code>bracket notation</code> to find the second-to-last character in the <code>lastName</code> string.", "Use <code>bracket notation</code> to find the second-to-last character in the <code>lastName</code> string.",
"Try looking at the <code>thirdToLastLetterOfFirstName</code> variable declaration if you get stuck." "Try looking at the <code>thirdToLastLetterOfFirstName</code> variable declaration if you get stuck."
], ],
@ -288,7 +288,7 @@
"assert((function(){if(difference === 12 && editor.getValue().match(/\\-/g)){return true;}else{return false;}})(), 'message: Make the variable <code>difference</code> equal 12.');" "assert((function(){if(difference === 12 && editor.getValue().match(/\\-/g)){return true;}else{return false;}})(), 'message: Make the variable <code>difference</code> equal 12.');"
], ],
"challengeSeed": [ "challengeSeed": [
"var difference = 45 - 0; //12", "var difference = 45 - 0;",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
"", "",
@ -390,10 +390,10 @@
"Change the <code>0.0</code> so that your quotient will equal <code>2.2</code>." "Change the <code>0.0</code> so that your quotient will equal <code>2.2</code>."
], ],
"tests": [ "tests": [
"assert((function(){if(quotient === 2.2 && editor.getValue().match(/\\//g)){return true;}else{return false;}})(), 'message: Make the variable <code>quotient</code> equal 2.2.');" "assert((function(){if(quotient === 2.2 && editor.getValue().match(/\\//g)){return true;}else{return false;}})(), 'message: Make the variable <code>quotient</code> equal <code>2.2</code>.');"
], ],
"challengeSeed": [ "challengeSeed": [
"var quotient = 0.0 / 2.0; // equals 2.2", "var quotient = 0.0 / 2.0;",
"", "",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
@ -418,7 +418,7 @@
"assert(typeof(myArray[1]) !== 'undefined' && typeof(myArray[1]) == 'number', 'message: The second item in <code>myArray</code> should be a <code>number</code>.');" "assert(typeof(myArray[1]) !== 'undefined' && typeof(myArray[1]) == 'number', 'message: The second item in <code>myArray</code> should be a <code>number</code>.');"
], ],
"challengeSeed": [ "challengeSeed": [
"// var array = [\"John\", 23];", "var array = [\"John\", 23];",
"", "",
"// Only change code below this line.", "// Only change code below this line.",
"", "",
@ -471,8 +471,9 @@
"assert((function(){if(typeof(myArray) != 'undefined' && typeof(myData) != 'undefined' && myArray[0] == myData){return true;}else{return false;}})(), 'message: The variable <code>myData</code> should equal the first value of <code>myArray</code>.');" "assert((function(){if(typeof(myArray) != 'undefined' && typeof(myData) != 'undefined' && myArray[0] == myData){return true;}else{return false;}})(), 'message: The variable <code>myData</code> should equal the first value of <code>myArray</code>.');"
], ],
"challengeSeed": [ "challengeSeed": [
"// var ourArray = [1,2,3];", "var ourArray = [1,2,3];",
"// var ourData = ourArray[0]; // equals 1", "",
"var ourData = ourArray[0]; // equals 1",
"", "",
"var myArray = [1,2,3];", "var myArray = [1,2,3];",
"", "",
@ -502,6 +503,7 @@
], ],
"challengeSeed": [ "challengeSeed": [
"var ourArray = [1,2,3];", "var ourArray = [1,2,3];",
"",
"ourArray[1] = 3; // ourArray now equals [1,3,3].", "ourArray[1] = 3; // ourArray now equals [1,3,3].",
"", "",
"var myArray = [1,2,3];", "var myArray = [1,2,3];",
@ -509,6 +511,7 @@
"// Only change code below this line.", "// Only change code below this line.",
"", "",
"", "",
"",
"// Only change code above this line.", "// Only change code above this line.",
"", "",
"if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}" "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}"
@ -527,18 +530,18 @@
], ],
"tests": [ "tests": [
"assert((function(d){if(d[0] == 'John' && d[1] == 23 && d[2] == undefined){return true;}else{return false;}})(myArray), 'message: <code>myArray</code> should only contain <code>[\"John\", 23]</code>.');", "assert((function(d){if(d[0] == 'John' && d[1] == 23 && d[2] == undefined){return true;}else{return false;}})(myArray), 'message: <code>myArray</code> should only contain <code>[\"John\", 23]</code>.');",
"assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return true;}else{return false;}})(removed), 'message: <code>removedFromMyArray</code> should only contain <code>[\"cat\", 2]</code>.');" "assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return true;}else{return false;}})(removedFromMyArray), 'message: <code>removedFromMyArray</code> should only contain <code>[\"cat\", 2]</code>.');"
], ],
"challengeSeed": [ "challengeSeed": [
"var ourArray = [1,2,3];", "var ourArray = [1,2,3];",
"var removedFromOurArray = numbers.pop(); // removedFromOurArray now equals 3, and ourArray now equals [1,2]", "",
"var removedFromOurArray = ourArray.pop(); // removedFromOurArray now equals 3, and ourArray now equals [1,2]",
"", "",
"var myArray = [\"John\", 23, [\"cat\", 2]];", "var myArray = [\"John\", 23, [\"cat\", 2]];",
"", "",
"// Only change code below this line.", "// Only change code below this line.",
"", "",
"", "var removedFromMyArray;",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
"", "",
@ -600,7 +603,7 @@
"", "",
"// Only change code below this line.", "// Only change code below this line.",
"", "",
"", "var removedFromMyArray;",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
"", "",
@ -725,7 +728,7 @@
"};", "};",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
"// We use this function to show you the value of your variable in your output box.", "",
"(function(z){return z;})(myDog);" "(function(z){return z;})(myDog);"
], ],
"type": "waypoint", "type": "waypoint",
@ -749,7 +752,7 @@
"Let's update <code>yourDog</code> object's name property. Let's change her name from \"Coder\" to \"Happy Coder\"." "Let's update <code>yourDog</code> object's name property. Let's change her name from \"Coder\" to \"Happy Coder\"."
], ],
"tests": [ "tests": [
"assert(myDog.name.match(/Happy Coder/), 'message: Update <code>myDog</code>'s <code>\"name\"</code> property to equal \"Happy Coder\".');" "assert(/happy coder/gi.test(myDog.name), 'message: Update <code>myDog</code>'s <code>\"name\"</code> property to equal \"Happy Coder\".');"
], ],
"challengeSeed": [ "challengeSeed": [
"var ourDog = {", "var ourDog = {",
@ -776,7 +779,7 @@
"", "",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
"// We use this function to show you the value of your variable in your output box.", "",
"(function(z){return z;})(myDog);" "(function(z){return z;})(myDog);"
], ],
"type": "waypoint", "type": "waypoint",
@ -818,7 +821,6 @@
"", "",
"// Only change code above this line.", "// Only change code above this line.",
"", "",
"// We use this function to show you the value of your variable in your output box.",
"(function(z){return z;})(myDog);" "(function(z){return z;})(myDog);"
], ],
"type": "waypoint", "type": "waypoint",
@ -840,7 +842,7 @@
" \"name\": \"Camper\",", " \"name\": \"Camper\",",
" \"legs\": 4,", " \"legs\": 4,",
" \"tails\": 1,", " \"tails\": 1,",
" \"friends\": [\"everything!\"]", " \"friends\": [\"everything!\"],",
" \"bark\": \"bow-wow\"", " \"bark\": \"bow-wow\"",
"};", "};",
"", "",
@ -850,7 +852,7 @@
" \"name\": \"Happy Coder\",", " \"name\": \"Happy Coder\",",
" \"legs\": 4,", " \"legs\": 4,",
" \"tails\": 1,", " \"tails\": 1,",
" \"friends\": [\"Free Code Camp Campers\"]", " \"friends\": [\"Free Code Camp Campers\"],",
" \"bark\": \"woof\"", " \"bark\": \"woof\"",
"};", "};",
"", "",
@ -860,7 +862,6 @@
"", "",
"// Only change code above this line.", "// Only change code above this line.",
"", "",
"// We use this function to show you the value of your variable in your output box.",
"(function(z){return z;})(myDog);" "(function(z){return z;})(myDog);"
], ],
"type": "waypoint", "type": "waypoint",
@ -887,18 +888,21 @@
], ],
"tests": [ "tests": [
"assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a <code>for</code> loop for this.');", "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a <code>for</code> loop for this.');",
"assert.deepEqual(myArray, [0,1,2,3,4], 'message: <code>myArray</code> should equal [0,1,2,3,4].');" "assert.deepEqual(myArray, [0,1,2,3,4], 'message: <code>myArray</code> should equal <code>[0,1,2,3,4]</code>');"
], ],
"challengeSeed": [ "challengeSeed": [
"var ourArray = [];", "var ourArray = [];",
"",
"for(var i = 0; i < 5; i++){", "for(var i = 0; i < 5; i++){",
" ourArray.push(i);", " ourArray.push(i);",
"}", "}",
"",
"var myArray = [];", "var myArray = [];",
"", "",
"// Only change code below this line.", "// Only change code below this line.",
"", "",
"",
"",
"// Only change code above this line.", "// Only change code above this line.",
"", "",
"if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}", "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}",
@ -918,26 +922,28 @@
"<code>&thinsp;&thinsp;ourArray.push(i);</code>", "<code>&thinsp;&thinsp;ourArray.push(i);</code>",
"<code>}</code>", "<code>}</code>",
"<code>ourArray</code> will now contain [0,2,4,6,8] ", "<code>ourArray</code> will now contain [0,2,4,6,8] ",
"Let's change our <code>initialization</code> and <code>final-expression</code> so we can count by odd numbers." "Let's change our <code>initialization</code> and <code>final-expression</code> so we can count by odd numbers.",
"Push the odd numbers from 1 through 9 to <code>myArray</code> using a <code>for loop</code>."
], ],
"tests":[ "tests":[
"assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a <code>for</code> loop for this.');", "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a <code>for</code> loop for this.');",
"assert.deepEqual(myArray, [1,3,5,7,9], 'message: <code>myArray</code> should equal [1,3,5,7,9].');" "assert.deepEqual(myArray, [1,3,5,7,9], 'message: <code>myArray</code> should equal <code>[1,3,5,7,9]</code>');"
], ],
"challengeSeed":[ "challengeSeed":[
"var ourArray = [];", "var ourArray = [];",
"",
"for(var i = 1; i < 10; i += 2){", "for(var i = 1; i < 10; i += 2){",
" ourArray.push(i);", " ourArray.push(i);",
"}", "}",
"",
"var myArray = [];", "var myArray = [];",
"", "",
"// Only change code below this line.", "// Only change code below this line.",
"", "",
"// Push the odd numbers from one through nine to myArray using a \"for loop\" like above.", "",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
"// We use this function to show you the value of your variable in your output box.", "",
"// You'll learn about functions soon.",
"if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}", "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}",
"" ""
], ],
@ -955,27 +961,29 @@
"<code>for(var i = 10; i > 0; i -= 2) {</code>", "<code>for(var i = 10; i > 0; i -= 2) {</code>",
"<code>&thinsp;&thinsp;ourArray.push(i);</code>", "<code>&thinsp;&thinsp;ourArray.push(i);</code>",
"<code>}</code>", "<code>}</code>",
"<code>ourArray</code> will now contain [10,8,6,4,2] ", "<code>ourArray</code> will now contain <code>[10,8,6,4,2]</code>",
"Let's change our <code>initialization</code> and <code>final-expression</code> so we can count backward by twos for numbers." "Let's change our <code>initialization</code> and <code>final-expression</code> so we can count backward by twos for numbers.",
"Push the odd numbers from 9 through 1 to <code>myArray</code> using a <code>for loop</code>."
], ],
"tests":[ "tests":[
"assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a <code>for</code> loop for this.');", "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a <code>for</code> loop for this.');",
"assert.deepEqual(myArray, [9,7,5,3,1], 'message: <code>myArray</code> should equal [9,7,5,3,1].');" "assert.deepEqual(myArray, [9,7,5,3,1], 'message: <code>myArray</code> should equal <code>[9,7,5,3,1]</code>');"
], ],
"challengeSeed":[ "challengeSeed":[
"ourArray = [];", "ourArray = [];",
"",
"for(var i = 9; i > 0; i -= 2){", "for(var i = 9; i > 0; i -= 2){",
" ourArray.push(i);", " ourArray.push(i);",
"}", "}",
"",
"var myArray = [];", "var myArray = [];",
"", "",
"// Only change code below this line.", "// Only change code below this line.",
"", "",
"// Push the odd numbers from nine through one to myArray using a \"for loop\" like above.", "",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
"// We use this function to show you the value of your variable in your output box.", "",
"// You'll learn about functions soon.",
"if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}", "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}",
"" ""
], ],
@ -994,17 +1002,19 @@
"<code>&thinsp;&thinsp;ourArray.push(i);</code>", "<code>&thinsp;&thinsp;ourArray.push(i);</code>",
"<code>&thinsp;&thinsp;i++;</code>", "<code>&thinsp;&thinsp;i++;</code>",
"<code>}</code>", "<code>}</code>",
"Let's try getting a while loop to work by pushing values to an array." "Let's try getting a while loop to work by pushing values to an array.",
"Push the numbers 0 through 4 to <code>myArray</code> using a <code>while loop</code>."
], ],
"tests": [ "tests": [
"assert(editor.getValue().match(/while/g), 'message: You should be using a <code>while</code> loop for this.');", "assert(editor.getValue().match(/while/g), 'message: You should be using a <code>while</code> loop for this.');",
"assert.deepEqual(myArray, [0,1,2,3,4], 'message: <code>myArray</code> should equal [0,1,2,3,4].');" "assert.deepEqual(myArray, [0,1,2,3,4], 'message: <code>myArray</code> should equal <code>[0,1,2,3,4]</code>');"
], ],
"challengeSeed": [ "challengeSeed": [
"var myArray = [];", "var myArray = [];",
"",
"// Only change code below this line.", "// Only change code below this line.",
"", "",
"// Push the numbers zero through four to myArray using a \"while loop\".", "",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
"", "",
@ -1020,16 +1030,17 @@
"description": [ "description": [
"Random numbers are useful for creating random behavior.", "Random numbers are useful for creating random behavior.",
"JavaScript has a <code>Math.random()</code> function that generates a random decimal number.", "JavaScript has a <code>Math.random()</code> function that generates a random decimal number.",
"Change </code>myFunction</code> to return a random number instead of returning <code>0</code>.", "Change <code>myFunction</code> to return a random number instead of returning <code>0</code>.",
"Note that you can return a function, just like you would return a variable or value." "Note that you can return a function, just like you would return a variable or value."
], ],
"tests": [ "tests": [
"assert(typeof(myFunction()) === \"number\", 'message: <code>myFunction</code> should return a random number.');", "assert(typeof(myFunction()) === \"number\", 'message: <code>myFunction</code> should return a random number.');",
"assert((myFunction()+''). match(/\\./g), 'message: The number returned by <code>myFunction</code> should be a decimal.');", "assert((myFunction()+''). match(/\\./g), 'message: The number returned by <code>myFunction</code> should be a decimal.');",
"assert(editor.getValue().match(/Math\\.random/g).length >= 2, 'message: You should be using <code>Math.random</code> to generate the random decimal number.');" "assert(editor.getValue().match(/Math\\.random/g).length >= 0, 'message: You should be using <code>Math.random</code> to generate the random decimal number.');"
], ],
"challengeSeed": [ "challengeSeed": [
"function myFunction() {", "function myFunction() {",
"",
" // Only change code below this line.", " // Only change code below this line.",
"", "",
" return 0;", " return 0;",
@ -1086,7 +1097,7 @@
"description": [ "description": [
"Instead of generating a random number between zero and a given number like we did before, we can generate a random number that falls within a range of two specific numbers.", "Instead of generating a random number between zero and a given number like we did before, we can generate a random number that falls within a range of two specific numbers.",
"To do this, we'll define a minimum number <code>min</code> and a maximum number <code>max</code>.", "To do this, we'll define a minimum number <code>min</code> and a maximum number <code>max</code>.",
"Here's the formula we'll use. Take a moment to read and try to understand what this code is doing.", "Here's the formula we'll use. Take a moment to read it and try to understand what this code is doing:",
"<code>Math.floor(Math.random() * (max - min + 1)) + min</code>", "<code>Math.floor(Math.random() * (max - min + 1)) + min</code>",
"Define two variables: <code>myMin</code> and </code>myMax</code>, and set them both equal to numbers.", "Define two variables: <code>myMin</code> and </code>myMax</code>, and set them both equal to numbers.",
"Then create a function called <code>myFunction</code> that returns a random number that's greater than or equal to <code>myMin</code>, and is less than <code>myMax</code>." "Then create a function called <code>myFunction</code> that returns a random number that's greater than or equal to <code>myMin</code>, and is less than <code>myMax</code>."
@ -1095,7 +1106,7 @@
"assert(myFunction() >= myMin, 'message: The random number generated by <code>myFunction</code> should be greater than or equal to your minimum number, <code>myMin</code>.');", "assert(myFunction() >= myMin, 'message: The random number generated by <code>myFunction</code> should be greater than or equal to your minimum number, <code>myMin</code>.');",
"assert(myFunction() <= myMax, 'message: The random number generated by <code>myFunction</code> should be less than or equal to your maximum number, <code>myMax</code>.');", "assert(myFunction() <= myMax, 'message: The random number generated by <code>myFunction</code> should be less than or equal to your maximum number, <code>myMax</code>.');",
"assert(myFunction() % 1 === 0 , 'message: The random number generated by <code>myFunction</code> should be an integer, not a decimal.');", "assert(myFunction() % 1 === 0 , 'message: The random number generated by <code>myFunction</code> should be an integer, not a decimal.');",
"assert((function(){if(editor.getValue().match(/myMax/g).length >= 3 && editor.getValue().match(/myMin/g).length >= 4 && editor.getValue().match(/Math.floor/g) && editor.getValue().match(/Math.random/g)){return true;}else{return false;}})(), 'message: You should be using a function called <code>myFunction()</code> to calculate your random number in your range.');" "assert((function(){if(editor.getValue().match(/myMax/g).length > 1 && editor.getValue().match(/myMin/g).length > 2 && editor.getValue().match(/Math.floor/g) && editor.getValue().match(/Math.random/g)){return true;}else{return false;}})(), 'message: <code>myFunction()</code> should use use both <code>myMax</code> and <code>myMin</code>, and return a random number in your range.');"
], ],
"challengeSeed": [ "challengeSeed": [
"var ourMin = 1;", "var ourMin = 1;",
@ -1110,13 +1121,15 @@
"", "",
"// Only change code below this line.", "// Only change code below this line.",
"", "",
"var myMin;",
"", "",
"var myMax;",
"", "",
"function myFunction() {",
"", "",
" return;",
"", "",
"", "}",
"",
"",
"", "",
"// Only change code above this line.", "// Only change code above this line.",
"", "",
@ -1142,13 +1155,14 @@
"Create <code>if</code> and <code>else</code> statements to return the string <code>\"heads\"</code> if the flip variable is zero, or else return the string <code>\"tails\"</code> if the flip variable is not zero." "Create <code>if</code> and <code>else</code> statements to return the string <code>\"heads\"</code> if the flip variable is zero, or else return the string <code>\"tails\"</code> if the flip variable is not zero."
], ],
"tests": [ "tests": [
"assert(editor.getValue().match(/if/g).length >= 2, 'message: Create a new if statement.');",
"assert(editor.getValue().match(/else/g).length >= 1, 'message: Created a new else statement.');",
"assert((function(){var result = myFunction();if(result === 'heads' || result === 'tails'){return true;} else {return false;}})(), 'message: <code>myFunction</code> should either return <code>heads</code> or <code>tails</code>.');", "assert((function(){var result = myFunction();if(result === 'heads' || result === 'tails'){return true;} else {return false;}})(), 'message: <code>myFunction</code> should either return <code>heads</code> or <code>tails</code>.');",
"assert((function(){var result = myFunction();if(result === 'heads' && flip === 0 || result === 'tails' && flip !== 0){return true;} else {return false;}})(), 'message: <code>myFunction</code> should return <code>heads</code> when flip equals 0 and <code>tails</code> when flip equals 1.');", "assert((function(){var result = myFunction();if(result === 'heads' && flip === 0 || result === 'tails' && flip !== 0){return true;} else {return false;}})(), 'message: <code>myFunction</code> should return <code>heads</code> when flip equals 0 and <code>tails</code> when flip equals 1.');"
"assert(editor.getValue().match(/if/g).length >= 4, 'message: You should have created a new if statement.');",
"assert(editor.getValue().match(/else/g).length >= 2, 'message: You should have created a new else statement.');"
], ],
"challengeSeed": [ "challengeSeed": [
"var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;", "var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;",
"",
"function myFunction() {", "function myFunction() {",
"", "",
" // Only change code below this line.", " // Only change code below this line.",

View File

@ -179,7 +179,8 @@
"title": "Center Text with Bootstrap", "title": "Center Text with Bootstrap",
"description": [ "description": [
"Now that we're using Bootstrap, we can center our heading element to make it look better. All we need to do is add the class <code>text-center</code> to our <code>h2</code> element.", "Now that we're using Bootstrap, we can center our heading element to make it look better. All we need to do is add the class <code>text-center</code> to our <code>h2</code> element.",
"Remember that you can add several classes to the same element by separating each of them with a space, like this: <code>&#60h2 class=\"red-text text-center\"&#62your text&#60/h2&#62</code>." "Remember that you can add several classes to the same element by separating each of them with a space, like this:",
"<code>&#60h2 class=\"red-text text-center\"&#62your text&#60/h2&#62</code>"
], ],
"tests": [ "tests": [
"assert($(\"h2\").hasClass(\"text-center\"), 'Your <code>h2</code> element should be centered by applying the class <code>text-center</code>')" "assert($(\"h2\").hasClass(\"text-center\"), 'Your <code>h2</code> element should be centered by applying the class <code>text-center</code>')"
@ -892,7 +893,8 @@
"<a href=\"http://i.imgur.com/O32cDWE.png\" data-lightbox=\"img-enlarge\"><img class=\"img-responsive\" src=\"http://i.imgur.com/O32cDWE.png\" title=\"Click to enlarge\" alt=\"An \"inline\" button is as small as the text it contains. In this image, it's centered. Below it is a \"block-level\" button, which stretches to fill the entire horizontal space.'></a>", "<a href=\"http://i.imgur.com/O32cDWE.png\" data-lightbox=\"img-enlarge\"><img class=\"img-responsive\" src=\"http://i.imgur.com/O32cDWE.png\" title=\"Click to enlarge\" alt=\"An \"inline\" button is as small as the text it contains. In this image, it's centered. Below it is a \"block-level\" button, which stretches to fill the entire horizontal space.'></a>",
"By using the <code>span</code> element, you can put several elements together, and even style different parts of the same element differently.", "By using the <code>span</code> element, you can put several elements together, and even style different parts of the same element differently.",
"Nest the word \"love\" in your \"Things cats love\" element below within a <code>span</code> element. Then give that <code>span</code> the class <code>text-danger</code> to make the text red.", "Nest the word \"love\" in your \"Things cats love\" element below within a <code>span</code> element. Then give that <code>span</code> the class <code>text-danger</code> to make the text red.",
"Here's how you would do this with the \"Top 3 things cats hate\" element: <code>&#60;p&#62;Top 3 things cats &#60;span class = \"text-danger\"&#62;hate&#60;/span&#62;&#60;/p&#62;</code>" "Here's how you would do this with the \"Top 3 things cats hate\" element:",
"<code>&#60;p&#62;Top 3 things cats &#60;span class = \"text-danger\"&#62;hate&#60;/span&#62;&#60;/p&#62;</code>"
], ],
"tests": [ "tests": [
"assert($(\"p span\") && $(\"p span\").length > 0, 'Your <code>span</code> element should be inside your <code>p</code> element.')", "assert($(\"p span\") && $(\"p span\").length > 0, 'Your <code>span</code> element should be inside your <code>p</code> element.')",
@ -2111,11 +2113,11 @@
"When we start using jQuery, we will modify HTML elements without needing to actually change them in HTML.", "When we start using jQuery, we will modify HTML elements without needing to actually change them in HTML.",
"Let's make sure that everyone knows they shouldn't actually modify any of this code directly.", "Let's make sure that everyone knows they shouldn't actually modify any of this code directly.",
"Remember that you can start a comment with <code>&#60;!--</code> and end a comment with <code>--&#62;</code>", "Remember that you can start a comment with <code>&#60;!--</code> and end a comment with <code>--&#62;</code>",
"Add a comment at the top of your HTML that says <code>You shouldn't need to modify code below this line</code>." "Add a comment at the top of your HTML that says <code>Only change code above this line.</code>"
], ],
"tests": [ "tests": [
"assert(editor.match(/<!--/g) && editor.match(/<!--/g).length > 0, 'Start a comment with <code>&#60;!--</code>.')", "assert(editor.match(/<!--/g) && editor.match(/<!--/g).length > 0, 'Start a comment with <code>&#60;!--</code>.')",
"assert(editor.match(/this line/g) && editor.match(/this line/g).length > 0, 'Your comment should have the text <code>You shouldn&#39;t need to modify code below this line</code>.')", "assert(editor.match(/this line/g) && editor.match(/this line/g).length > 0, 'Your comment should have the text <code>Only change code above this line</code>.')",
"assert(editor.match(/-->.*\\n+.+/g), 'Be sure to close your comment with <code>--&#62;</code>.')" "assert(editor.match(/-->.*\\n+.+/g), 'Be sure to close your comment with <code>--&#62;</code>.')"
], ],
"challengeSeed": [ "challengeSeed": [

View File

@ -512,9 +512,9 @@
], ],
"tests": [ "tests": [
"assert($(\"h2\").css(\"color\") === \"rgb(255, 0, 0)\", 'Your <code>h2</code> element should be red.')", "assert($(\"h2\").css(\"color\") === \"rgb(255, 0, 0)\", 'Your <code>h2</code> element should be red.')",
"assert($(\"h2\").hasClass(\"red-text\"), 'Your <code>h2</code> element should have the class <code>red-text</code>')", "assert($(\"h2\").hasClass(\"red-text\"), 'Your <code>h2</code> element should have the class <code>red-text</code>.')",
"assert($(\"p\").css(\"color\") === \"rgb(255, 0, 0)\", 'Your <code>p</code> element should be red.')", "assert($(\"p\").css(\"color\") === \"rgb(255, 0, 0)\", 'Your <code>p</code> element should be red.')",
"assert($(\"p\").hasClass(\"red-text\"), 'Your <code>p</code> element should have the class <code>red-text</code>')" "assert($(\"p\").hasClass(\"red-text\"), 'Your <code>p</code> element should have the class <code>red-text</code>.')"
], ],
"challengeSeed": [ "challengeSeed": [
"<style>", "<style>",
@ -3151,7 +3151,10 @@
"Now let's start fresh and talk about CSS inheritance.", "Now let's start fresh and talk about CSS inheritance.",
"Every HTML page has a <code>body</code> element.", "Every HTML page has a <code>body</code> element.",
"We can prove that the <code>body</code> element exists here by giving it a <code>background-color</code> of black.", "We can prove that the <code>body</code> element exists here by giving it a <code>background-color</code> of black.",
"We can do this by adding <code>body { background-color: black; }</code> to our <code>style</code> element." "We can do this by adding the following to our <code>style</code> element:",
"<code>body {</code>",
"<code>&thinsp;&thinsp;background-color: black;</code>",
"<code>}</code>"
], ],
"tests": [ "tests": [
"assert($(\"body\").css(\"background-color\") === \"rgb(0, 0, 0)\", 'Give your <code>body</code> element the <code>background-color</code> of black.')" "assert($(\"body\").css(\"background-color\") === \"rgb(0, 0, 0)\", 'Give your <code>body</code> element the <code>background-color</code> of black.')"
@ -3226,7 +3229,7 @@
"For example, your <code>h1</code> element can't be both green and pink at the same time.", "For example, your <code>h1</code> element can't be both green and pink at the same time.",
"Let's see what happens when we create a class that makes text pink, then apply it to an element. Will our class <code>override</code> the <code>body</code> element's <code>color: green;</code> CSS property?", "Let's see what happens when we create a class that makes text pink, then apply it to an element. Will our class <code>override</code> the <code>body</code> element's <code>color: green;</code> CSS property?",
"Create a CSS class called <code>pink-text</code> that gives an element the color pink.", "Create a CSS class called <code>pink-text</code> that gives an element the color pink.",
"Give your <code>h1</code> element the class of <code>pink-text</code>" "Give your <code>h1</code> element the class of <code>pink-text</code>."
], ],
"tests": [ "tests": [
"assert($(\"h1\").hasClass(\"pink-text\"), 'Your <code>h1</code> element should have the class <code>pink-text</code>.')", "assert($(\"h1\").hasClass(\"pink-text\"), 'Your <code>h1</code> element should have the class <code>pink-text</code>.')",
@ -3313,7 +3316,7 @@
"Leave the <code>blue-text</code> and <code>pink-text</code> classes on your <code>h1</code> element.", "Leave the <code>blue-text</code> and <code>pink-text</code> classes on your <code>h1</code> element.",
"Create a CSS declaration for your <code>orange-text</code> id in your <code>style</code> element. Here's an example of what this looks like:", "Create a CSS declaration for your <code>orange-text</code> id in your <code>style</code> element. Here's an example of what this looks like:",
"<code>#brown-text {</code>", "<code>#brown-text {</code>",
"<code>color: brown;</code>", "<code>&thinsp;&thinsp;color: brown;</code>",
"<code>}</code>" "<code>}</code>"
], ],
"tests": [ "tests": [

View File

@ -23,7 +23,7 @@
"challengeSeed": [ "challengeSeed": [
"", "",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -72,7 +72,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -122,7 +122,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -174,7 +174,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -225,7 +225,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -277,7 +277,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -328,7 +328,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -382,7 +382,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -433,7 +433,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -481,7 +481,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -533,7 +533,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -587,7 +587,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -643,7 +643,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -699,7 +699,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -756,7 +756,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -813,7 +813,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",
@ -869,7 +869,7 @@
" });", " });",
"fcces", "fcces",
"", "",
"<!-- You shouldn't need to modify code below this line -->", "<!-- Only change code above this line. -->",
"", "",
"<div class=\"container-fluid\">", "<div class=\"container-fluid\">",
" <h3 class=\"text-primary text-center\">jQuery Playground</h3>", " <h3 class=\"text-primary text-center\">jQuery Playground</h3>",

View File

@ -109,13 +109,17 @@
], ],
"challengeSeed":[ "challengeSeed":[
"var Car = function() {", "var Car = function() {",
" this.gear = 1;", "",
" gear = 1;",
"",
" function addStyle(styleMe){", " function addStyle(styleMe){",
" return 'The Current Gear Is: ' + styleMe;", " return 'The Current Gear Is: ' + styleMe;",
" }", " }",
"",
" this.getGear = function() {", " this.getGear = function() {",
" return addStyle(this.gear);", " return addStyle(this.gear);",
" };", " };",
"",
"};", "};",
"", "",
"var Bike = function() {", "var Bike = function() {",
@ -123,6 +127,7 @@
" // Only change code below this line.", " // Only change code below this line.",
"", "",
" this.speed = 100;", " this.speed = 100;",
"",
" function addUnit(value) {", " function addUnit(value) {",
" return value + \"KM/H\";", " return value + \"KM/H\";",
" }", " }",
@ -203,6 +208,9 @@
"", "",
"", "",
"", "",
"",
"",
"",
"// Only change code above this line.", "// Only change code above this line.",
"", "",
"(function() {return array;})();" "(function() {return array;})();"
@ -239,6 +247,9 @@
"", "",
"", "",
"", "",
"",
"",
"",
"// Only change code above this line.", "// Only change code above this line.",
"", "",
"(function() {return singleVal;})();" "(function() {return singleVal;})();"