fix exact change and QA all JS challenges

pull/18182/head
Quincy Larson 2015-09-30 18:33:32 -07:00
parent 7eb99cfe97
commit eb7aaf4c64
4 changed files with 131 additions and 131 deletions

View File

@ -126,26 +126,26 @@
"}",
"",
"// Example cash-in-drawer array:",
"// [['PENNY', 1.01],",
"// ['NICKEL', 2.05],",
"// ['DIME', 3.10],",
"// ['QUARTER', 4.25],",
"// ['ONE', 90.00],",
"// ['FIVE', 55.00],",
"// ['TEN', 20.00],",
"// ['TWENTY', 60.00],",
"// ['ONE HUNDRED', 100.00]]",
"// [[\"PENNY\", 1.01],",
"// [\"NICKEL\", 2.05],",
"// [\"DIME\", 3.10],",
"// [\"QUARTER\", 4.25],",
"// [\"ONE\", 90.00],",
"// [\"FIVE\", 55.00],",
"// [\"TEN\", 20.00],",
"// [\"TWENTY\", 60.00],",
"// [\"ONE HUNDRED\", 100.00]]",
"",
"drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);"
"drawer(19.50, 20.00, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.10], [\"QUARTER\", 4.25], [\"ONE\", 90.00], [\"FIVE\", 55.00], [\"TEN\", 20.00], [\"TWENTY\", 60.00], [\"ONE HUNDRED\", 100.00]]);"
],
"tests": [
"assert.isArray(drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]), 'message: <code>drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]])</code> should return an array.');",
"assert.isString(drawer(19.50, 20.00, [['PENNY', 0.01], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]]), 'message: <code>drawer(19.50, 20.00, [['PENNY', 0.01], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]])</code> should return a string.');",
"assert.isString(drawer(19.50, 20.00, [['PENNY', 0.50], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]]), 'message: <code>drawer(19.50, 20.00, [['PENNY', 0.50], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]])</code> should return a string.');",
"assert.deepEqual(drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]), [['QUARTER', 0.50]], 'message: <code>drawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]])</code> should return <code>[['QUARTER', 0.50]]</code>.');",
"assert.deepEqual(drawer(3.26, 100.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]), [['TWENTY', 60.00], ['TEN', 20.00], ['FIVE', 15], ['ONE', 1], ['QUARTER', 0.50], ['DIME', 0.20], ['PENNY', 0.04]], 'message: <code>drawer(3.26, 100.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]])</code> should return <code>[['TWENTY', 60.00], ['TEN', 20.00], ['FIVE', 15], ['ONE', 1], ['QUARTER', 0.50], ['DIME', 0.20], ['PENNY', 0.04]]</code>.');",
"assert.deepEqual(drawer(19.50, 20.00, [['PENNY', 0.01], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]]), 'Insufficient Funds', 'message: <code>drawer(19.50, 20.00, [['PENNY', 0.01], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]])</code> should return \"Insufficient Funds\".');",
"assert.deepEqual(drawer(19.50, 20.00, [['PENNY', 0.50], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]]), \"Closed\", 'message: <code>drawer(19.50, 20.00, [['PENNY', 0.50], ['NICKEL', 0], ['DIME', 0], ['QUARTER', 0], ['ONE', 0], ['FIVE', 0], ['TEN', 0], ['TWENTY', 0], ['ONE HUNDRED', 0]])</code> should return \"Closed\".');"
"assert.isArray(drawer(19.50, 20.00, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.10], [\"QUARTER\", 4.25], [\"ONE\", 90.00], [\"FIVE\", 55.00], [\"TEN\", 20.00], [\"TWENTY\", 60.00], [\"ONE HUNDRED\", 100.00]]), 'message: <code>drawer(19.50, 20.00, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.10], [\"QUARTER\", 4.25], [\"ONE\", 90.00], [\"FIVE\", 55.00], [\"TEN\", 20.00], [\"TWENTY\", 60.00], [\"ONE HUNDRED\", 100.00]])</code> should return an array.');",
"assert.isString(drawer(19.50, 20.00, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]), 'message: <code>drawer(19.50, 20.00, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return a string.');",
"assert.isString(drawer(19.50, 20.00, [[\"PENNY\", 0.50], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]), 'message: <code>drawer(19.50, 20.00, [[\"PENNY\", 0.50], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return a string.');",
"assert.deepEqual(drawer(19.50, 20.00, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.10], [\"QUARTER\", 4.25], [\"ONE\", 90.00], [\"FIVE\", 55.00], [\"TEN\", 20.00], [\"TWENTY\", 60.00], [\"ONE HUNDRED\", 100.00]]), [[\"QUARTER\", 0.50]], 'message: <code>drawer(19.50, 20.00, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.10], [\"QUARTER\", 4.25], [\"ONE\", 90.00], [\"FIVE\", 55.00], [\"TEN\", 20.00], [\"TWENTY\", 60.00], [\"ONE HUNDRED\", 100.00]])</code> should return <code>[[\"QUARTER\", 0.50]]</code>.');",
"assert.deepEqual(drawer(3.26, 100.00, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.10], [\"QUARTER\", 4.25], [\"ONE\", 90.00], [\"FIVE\", 55.00], [\"TEN\", 20.00], [\"TWENTY\", 60.00], [\"ONE HUNDRED\", 100.00]]), [[\"TWENTY\", 60.00], [\"TEN\", 20.00], [\"FIVE\", 15], [\"ONE\", 1], [\"QUARTER\", 0.50], [\"DIME\", 0.20], [\"PENNY\", 0.04]], 'message: <code>drawer(3.26, 100.00, [[\"PENNY\", 1.01], [\"NICKEL\", 2.05], [\"DIME\", 3.10], [\"QUARTER\", 4.25], [\"ONE\", 90.00], [\"FIVE\", 55.00], [\"TEN\", 20.00], [\"TWENTY\", 60.00], [\"ONE HUNDRED\", 100.00]])</code> should return <code>[[\"TWENTY\", 60.00], [\"TEN\", 20.00], [\"FIVE\", 15], [\"ONE\", 1], [\"QUARTER\", 0.50], [\"DIME\", 0.20], [\"PENNY\", 0.04]]</code>.');",
"assert.deepEqual(drawer(19.50, 20.00, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]), \"Insufficient Funds\", 'message: <code>drawer(19.50, 20.00, [[\"PENNY\", 0.01], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return \"Insufficient Funds\".');",
"assert.deepEqual(drawer(19.50, 20.00, [[\"PENNY\", 0.50], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]]), \"Closed\", 'message: <code>drawer(19.50, 20.00, [[\"PENNY\", 0.50], [\"NICKEL\", 0], [\"DIME\", 0], [\"QUARTER\", 0], [\"ONE\", 0], [\"FIVE\", 0], [\"TEN\", 0], [\"TWENTY\", 0], [\"ONE HUNDRED\", 0]])</code> should return \"Closed\".');"
],
"MDNlinks": [
"Global Object"

View File

@ -13,7 +13,7 @@
"<code>console.log('Hello world!')</code>"
],
"tests":[
"assert(editor.getValue().match(/console\\.log\\(/gi), 'You should use the console.log method to log \"Hello world!\" to your JavaScript console.');"
"assert(editor.getValue().match(/console\\.log\\(/gi), 'message: You should use the console.log method to log \"Hello world!\" to your JavaScript console.');"
],
"challengeSeed":[
"",
@ -37,10 +37,10 @@
"<code>console.log(typeof({}));</code>"
],
"tests":[
"assert(editor.getValue().match(/console\\.log\\(typeof\\(\"\"\\)\\);/gi), 'You should <code>console.log</code> the <code>typeof</code> a string.');",
"assert(editor.getValue().match(/console\\.log\\(typeof\\(0\\)\\);/gi), 'You should <code>console.log</code> the <code>typeof</code> a number.');",
"assert(editor.getValue().match(/console\\.log\\(typeof\\(\\[\\]\\)\\);/gi), 'You should <code>console.log</code> the <code>typeof</code> an array.');",
"assert(editor.getValue().match(/console\\.log\\(typeof\\(\\{\\}\\)\\);/gi), 'You should <code>console.log</code> the <code>typeof</code> a object.');"
"assert(editor.getValue().match(/console\\.log\\(typeof\\(\"\"\\)\\);/gi), 'message: You should <code>console.log</code> the <code>typeof</code> a string.');",
"assert(editor.getValue().match(/console\\.log\\(typeof\\(0\\)\\);/gi), 'message: You should <code>console.log</code> the <code>typeof</code> a number.');",
"assert(editor.getValue().match(/console\\.log\\(typeof\\(\\[\\]\\)\\);/gi), 'message: You should <code>console.log</code> the <code>typeof</code> an array.');",
"assert(editor.getValue().match(/console\\.log\\(typeof\\(\\{\\}\\)\\);/gi), 'message: You should <code>console.log</code> the <code>typeof</code> a object.');"
],
"challengeSeed":[
"",

View File

@ -17,9 +17,9 @@
"And one more thing you need to notice. Starting at this waypoint in JavaScript related challenges (except AngularJS, all Ziplines, Git, Node.js and Express.js, MongoDB and Full Stack JavaScript Projects) you can see contents of <code>assert()</code> functions (in some challenges <code>except()</code>, <code>assert.equal()</code> and so on) which are used to test your code. It's part of these challenges that you are able to see the tests that are running against your code."
],
"tests":[
"assert(editor.getValue().match(/(\\/\\/)...../g), 'Create a <code>//</code> style comment that contains at least five letters');",
"assert(editor.getValue().match(/(\\/\\*)[\\w\\W]{5,}(?=\\*\\/)/gm), 'Create a <code>/* */</code> style comment that contains at least five letters.');",
"assert(editor.getValue().match(/(\\*\\/)/g), 'Make sure that you close the comment with a <code>*/</code>');"
"assert(editor.getValue().match(/(\\/\\/)...../g), 'message: Create a <code>//</code> style comment that contains at least five letters');",
"assert(editor.getValue().match(/(\\/\\*)[\\w\\W]{5,}(?=\\*\\/)/gm), 'message: Create a <code>/* */</code> style comment that contains at least five letters.');",
"assert(editor.getValue().match(/(\\*\\/)/g), 'message: Make sure that you close the comment with a <code>*/</code>');"
],
"challengeSeed":[
],
@ -36,8 +36,8 @@
"Let's modify our <code>welcomeToBooleans</code>function so that it will return <code>true</code>instead of <code>false</code>when the run button is clicked."
],
"tests": [
"assert(typeof(welcomeToBooleans()) === 'boolean', 'The <code>welcomeToBooleans()</code> function should return a boolean &#40;true/false&#41; value.');",
"assert(welcomeToBooleans() === true, '<code>welcomeToBooleans()</code> should return true.');"
"assert(typeof(welcomeToBooleans()) === 'boolean', 'message: The <code>welcomeToBooleans()</code> function should return a boolean &#40;true/false&#41; value.');",
"assert(welcomeToBooleans() === true, 'message: <code>welcomeToBooleans()</code> should return true.');"
],
"challengeSeed": [
"function welcomeToBooleans() {",
@ -66,7 +66,7 @@
"Look at the <code>ourName</code> example if you get stuck."
],
"tests": [
"assert((function(){if(typeof(myName) !== \"undefined\" && typeof(myName) === \"string\" && myName.length > 0){return true;}else{return false;}})(), '<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": [
"// var ourName = \"Free Code Camp\";",
@ -90,8 +90,8 @@
"Now let's create two new string variables: <code>myFirstName</code>and <code>myLastName</code> and assign them the values of your first and last name, respectively."
],
"tests": [
"assert((function(){if(typeof(myFirstName) !== \"undefined\" && typeof(myFirstName) === \"string\" && myFirstName.length > 0){return true;}else{return false;}})(), '<code>myFirstName</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;}})(), '<code>myLastName</code> should be a string with at least one character in it.');"
"assert((function(){if(typeof(myFirstName) !== \"undefined\" && typeof(myFirstName) === \"string\" && myFirstName.length > 0){return true;}else{return false;}})(), 'message: <code>myFirstName</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": [
"// var name = \"Alan Turing\";",
@ -117,8 +117,8 @@
"Use the <code>.length</code> property to count the number of characters in the <code>lastName</code> variable."
],
"tests": [
"assert((function(){if(typeof(lastNameLength) !== \"undefined\" && typeof(lastNameLength) === \"number\" && lastNameLength === 8){return true;}else{return false;}})(), '<code>lastNameLength</code> should be equal to eight.');",
"assert((function(){if(editor.getValue().match(/\\.length/gi) && editor.getValue().match(/\\.length/gi).length >= 2 && editor.getValue().match(/var lastNameLength \\= 0;/gi) && editor.getValue().match(/var lastNameLength \\= 0;/gi).length >= 1){return true;}else{return false;}})(), 'You should be getting the length of <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>.');"
"assert((function(){if(typeof(lastNameLength) !== \"undefined\" && typeof(lastNameLength) === \"number\" && lastNameLength === 8){return true;}else{return false;}})(), 'message: <code>lastNameLength</code> should be equal to eight.');",
"assert((function(){if(editor.getValue().match(/\\.length/gi) && editor.getValue().match(/\\.length/gi).length >= 2 && editor.getValue().match(/var lastNameLength \\= 0;/gi) && editor.getValue().match(/var lastNameLength \\= 0;/gi).length >= 1){return true;}else{return false;}})(), 'message: You should be getting the length of <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>.');"
],
"challengeSeed": [
"var firstNameLength = 0;",
@ -155,7 +155,7 @@
"Try looking at the <code>firstLetterOfFirstName</code> variable declaration if you get stuck."
],
"tests": [
"assert((function(){if(typeof(firstLetterOfLastName) !== \"undefined\" && editor.getValue().match(/\\[0\\]/gi) && typeof(firstLetterOfLastName) === \"string\" && firstLetterOfLastName === \"L\"){return true;}else{return false;}})(), 'The first letter of <code>firstLetterOfLastName</code> should be a <code>\"L\"</code>.');"
"assert((function(){if(typeof(firstLetterOfLastName) !== \"undefined\" && editor.getValue().match(/\\[0\\]/gi) && typeof(firstLetterOfLastName) === \"string\" && firstLetterOfLastName === \"L\"){return true;}else{return false;}})(), 'message: The first letter of <code>firstLetterOfLastName</code> should be a <code>\"L\"</code>.');"
],
"challengeSeed": [
"var firstLetterOfFirstName = \"\";",
@ -189,7 +189,7 @@
"Try looking at the <code>secondLetterOfFirstName</code> variable declaration if you get stuck."
],
"tests": [
"assert(thirdLetterOfLastName === 'v', 'The third letter of <code>lastName</code> should be a <code>\"v\"</code>.');"
"assert(thirdLetterOfLastName === 'v', 'message: The third letter of <code>lastName</code> should be a \"v\".');"
],
"challengeSeed": [
"var firstName = \"Ada\";",
@ -220,8 +220,8 @@
"Try looking at the <code>lastLetterOfFirstName</code> variable declaration if you get stuck."
],
"tests": [
"assert(lastLetterOfLastName === \"e\", '<code>lastLetterOfLastName</code> should be <code>\"e\"</code>.');",
"assert(editor.getValue().match(/\\.length/g).length === 2, 'You have to use <code>.length</code> to get the last letter.');"
"assert(lastLetterOfLastName === \"e\", 'message: <code>lastLetterOfLastName</code> should be \"e\".');",
"assert(editor.getValue().match(/\\.length/g).length === 2, 'message: You have to use <code>.length</code> to get the last letter.');"
],
"challengeSeed": [
"var firstName = \"Ada\";",
@ -252,8 +252,8 @@
"Try looking at the <code>thirdToLastLetterOfFirstName</code> variable declaration if you get stuck."
],
"tests": [
"assert(secondToLastLetterOfLastName === 'c', '<code>secondToLastLetterOfLastName</code> should be <code>\"c\"</code>.');",
"assert(editor.getValue().match(/\\.length/g).length === 2, 'You have to use .length to get the second last letter.');"
"assert(secondToLastLetterOfLastName === 'c', 'message: <code>secondToLastLetterOfLastName</code> should be \"c\".');",
"assert(editor.getValue().match(/\\.length/g).length === 2, 'message: You have to use <code>.length</code> to get the second last letter.');"
],
"challengeSeed": [
"var firstName = \"Ada\";",
@ -283,7 +283,7 @@
"Replace the <code>0</code> with the correct number so you can get the result mentioned in the comment."
],
"tests": [
"assert((function(){if(sum === 20 && editor.getValue().match(/\\+/g).length >= 2){return true;}else{return false;}})(), 'Make the variable <code>sum</code> equal 20.');"
"assert((function(){if(sum === 20 && editor.getValue().match(/\\+/g).length >= 2){return true;}else{return false;}})(), 'message: Make the variable <code>sum</code> equal 20.');"
],
"challengeSeed": [
"var sum = 10 + 0; //make this equal to 20 by changing the 0 into the appropriate number.",
@ -306,7 +306,7 @@
"Replace the <code>0</code> with the correct number so you can get the result mentioned in the comment."
],
"tests": [
"assert((function(){if(difference === 12 && editor.getValue().match(/\\-/g)){return true;}else{return false;}})(), '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": [
"var difference = 45 - 0; //make this equal to 12 by changing the 0 into the appropriate number.",
@ -329,7 +329,7 @@
"Replace the <code>0</code> with the correct number so you can get the result mentioned in the comment."
],
"tests": [
"assert((function(){if(product === 80 && editor.getValue().match(/\\*/g)){return true;}else{return false;}})(), 'Make the variable <code>product</code> equal 80.');"
"assert((function(){if(product === 80 && editor.getValue().match(/\\*/g)){return true;}else{return false;}})(), 'message: Make the variable <code>product</code> equal 80.');"
],
"challengeSeed": [
"var product = 8 * 0; // Make this equal to 80 by changing the 0 into the appropriate number.",
@ -352,7 +352,7 @@
"Replace the <code>0</code> with the correct number so you can get the result mentioned in the comment."
],
"tests": [
"assert((function(){if(quotient === 2 && editor.getValue().match(/var\\s*?quotient\\s*?\\=\\s*?\\d+\\s*?\\/\\s*?\\d+\\s*?;/g)){return true;}else{return false;}})(), 'Make the variable <code>quotient</code> equal 2.');"
"assert((function(){if(quotient === 2 && editor.getValue().match(/var\\s*?quotient\\s*?\\=\\s*?\\d+\\s*?\\/\\s*?\\d+\\s*?;/g)){return true;}else{return false;}})(), 'message: Make the variable <code>quotient</code> equal 2.');"
],
"challengeSeed": [
"var quotient = 66 / 0; //make this equal to 2 by changing the 0 into the appropriate number.",
@ -374,7 +374,7 @@
"Let's create a variable <code>myDecimal</code> and give it a decimal value."
],
"tests": [
"assert((function(){if(typeof(myDecimal) !== \"undefined\" && typeof(myDecimal) === \"number\" && editor.getValue().match(/\\./g).length >=2){return true;}else{return false;}})(), 'myDecimal should be a decimal point number.');"
"assert((function(){if(typeof(myDecimal) !== \"undefined\" && typeof(myDecimal) === \"number\" && editor.getValue().match(/\\./g).length >=2){return true;}else{return false;}})(), 'message: <code>myDecimal</code> should be a decimal point number.');"
],
"challengeSeed": [
"// var ourDecimal = 5.7;",
@ -399,8 +399,8 @@
"Replace the <code>0.0</code> with the correct number so that you get the result mentioned in the comments."
],
"tests": [
"assert((function(){if(product === 5.0 && editor.getValue().match(/\\*/g)){return true;}else{return false;}})(), 'Make the variable <code>product</code> equal 5.0.');",
"assert((function(){if(quotient === 2.2 && editor.getValue().match(/\\//g)){return true;}else{return false;}})(), 'Make the variable <code>quotient</code> equal 2.2.');"
"assert((function(){if(product === 5.0 && editor.getValue().match(/\\*/g)){return true;}else{return false;}})(), 'message: Make the variable <code>product</code> equal 5.0.');",
"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.');"
],
"challengeSeed": [
"var quotient = 4.4 / 2.0; // equals 2.2",
@ -426,9 +426,9 @@
"Refer to the commented code in the text editor if you get stuck."
],
"tests": [
"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>.');"
"assert(typeof(myArray) == 'object', 'message: <code>myArray</code> should be an <code>array</code>.');",
"assert(typeof(myArray[0]) !== 'undefined' && typeof(myArray[0]) == 'string', 'message: The first item in <code>myArray</code> should be a <code>string</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": [
"// var array = [\"John\", 23];",
@ -454,7 +454,7 @@
"Let's now go create a nested array called <code>myArray</code>."
],
"tests":[
"assert(Array.isArray(myArray) && myArray.some(Array.isArray), '<code>myArray</code> should have at least one array nested within another array.');"
"assert(Array.isArray(myArray) && myArray.some(Array.isArray), 'message: <code>myArray</code> should have at least one array nested within another array.');"
],
"challengeSeed":[
"var ourArray = [[\"the universe\", \"everything\", 42]];",
@ -484,7 +484,7 @@
"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 <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":[
"// var ourArray = [1,2,3];",
@ -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;}})(), '<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>.');"
"assert((function(){if(typeof(myArray) != 'undefined' && myArray[0] == 3 && myArray[1] == 2 && myArray[2] == 3){return true;}else{return false;}})(), 'message: <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;}})(), 'message: You should be using correct index to modify the value in <code>myArray</code>.');"
],
"challengeSeed":[
"var ourArray = [1,2,3];",
@ -544,8 +544,8 @@
"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), '<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).');"
"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>removed</code> should only contain <code>[\"cat\"], 2</code>.');"
],
"challengeSeed": [
"// var numbers = [1,2,3];",
@ -576,7 +576,7 @@
"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), '<code>myArray</code> 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), 'message: <code>myArray</code> should now equal <code>[\"John\", 23, [\"dog\", 3]]</code>.');"
],
"challengeSeed": [
"var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];",
@ -607,8 +607,8 @@
"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), '<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>.');"
"assert((function(d){if(d[0] == 23 && d[1][0] == 'dog' && d[1][1] == 3 && d[2] == undefined){return true;}else{return false;}})(myArray), 'message: <code>myArray</code> should now equal <code>[23, [\"dog\", 3]]</code>.');",
"assert((function(d){if(d === 'John' && typeof(myRemoved) === 'string'){return true;}else{return false;}})(myRemoved), 'message: <code>myRemoved</code> should contain <code>\"John\"</code>.');"
],
"challengeSeed": [
"var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];",
@ -638,7 +638,7 @@
"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]]).');"
"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), 'message: <code>myArray</code> should now have [\"Paul\", 23, [\"dog\", 3]]).');"
],
"challengeSeed": [
"var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];",
@ -677,7 +677,7 @@
"Create and call a function called <code>myFunction</code> that returns the sum of <code>a</code> and <code>b</code>."
],
"tests":[
"assert((function(){if(typeof(f) !== \"undefined\" && f === a + b){return true;}else{return false;}})(), 'Your function should return the value of a + b');"
"assert((function(){if(typeof(f) !== \"undefined\" && f === a + b){return true;}else{return false;}})(), 'message: Your function should return the value of a + b');"
],
"challengeSeed":[
"var a = 4;",
@ -723,10 +723,10 @@
"Let's try to make an object that represents a dog called <code>myDog</code> which contains the properties <code>'name'</code> (String), <code>'legs'</code> (Number), <code>'tails'</code> (Number) and <code>'friends'</code> (Array)!"
],
"tests":[
"assert((function(z){if(z.hasOwnProperty(\"name\") && z.name !== undefined && typeof(z.name) === \"string\"){return true;}else{return false;}})(myDog), '<code>myDog</code> should contain the property <code>name</code> and it should be a <code>string</code>.');",
"assert((function(z){if(z.hasOwnProperty(\"legs\") && z.legs !== undefined && typeof(z.legs) === \"number\"){return true;}else{return false;}})(myDog), '<code>myDog</code> should contain the property <code>legs</code> and it should be a <code>number</code>.');",
"assert((function(z){if(z.hasOwnProperty(\"tails\") && z.tails !== undefined && typeof(z.tails) === \"number\"){return true;}else{return false;}})(myDog), '<code>myDog</code> should contain the property <code>tails</code> and it should be a <code>number</code>.');",
"assert((function(z){if(z.hasOwnProperty(\"friends\") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), '<code>myDog</code> should contain the property <code>friends</code> and it should be an <code>array</code>.');"
"assert((function(z){if(z.hasOwnProperty(\"name\") && z.name !== undefined && typeof(z.name) === \"string\"){return true;}else{return false;}})(myDog), 'message: <code>myDog</code> should contain the property <code>name</code> and it should be a <code>string</code>.');",
"assert((function(z){if(z.hasOwnProperty(\"legs\") && z.legs !== undefined && typeof(z.legs) === \"number\"){return true;}else{return false;}})(myDog), 'message: <code>myDog</code> should contain the property <code>legs</code> and it should be a <code>number</code>.');",
"assert((function(z){if(z.hasOwnProperty(\"tails\") && z.tails !== undefined && typeof(z.tails) === \"number\"){return true;}else{return false;}})(myDog), 'message: <code>myDog</code> should contain the property <code>tails</code> and it should be a <code>number</code>.');",
"assert((function(z){if(z.hasOwnProperty(\"friends\") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), 'message: <code>myDog</code> should contain the property <code>friends</code> and it should be an <code>array</code>.');"
],
"challengeSeed":[
"// var ourDog = {",
@ -765,8 +765,8 @@
"Let's add the property <code>\"bark\"</code>, and delete the property <code>\"tails\"</code>."
],
"tests":[
"assert(myDog.bark !== undefined, 'Add the property <code>\"bark\"</code> to <code>myDog</code>.');",
"assert(myDog.tails === undefined, 'Delete the property <code>\"tails\"</code> from <code>myDog</code>.');"
"assert(myDog.bark !== undefined, 'message: Add the property <code>\"bark\"</code> to <code>myDog</code>.');",
"assert(myDog.tails === undefined, 'message: Delete the property <code>\"tails\"</code> from <code>myDog</code>.');"
],
"challengeSeed":[
"// var ourDog = {",
@ -816,8 +816,8 @@
"Let's try getting a for loop to work by pushing values to an array."
],
"tests":[
"assert(editor.getValue().match(/for/g), 'You should be using a <code>for</code> loop for this.');",
"assert.deepEqual(myArray, [0,1,2,3,4], '<code>myArray</code> should equal [0,1,2,3,4].');"
"assert(editor.getValue().match(/for/g), '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].');"
],
"challengeSeed":[
"ourArray = [];",
@ -855,8 +855,8 @@
"Let's try getting a while loop to work by pushing values to an array."
],
"tests":[
"assert(editor.getValue().match(/while/g), 'You should be using a <code>while</code> loop for this.');",
"assert.deepEqual(myArray, [0,1,2,3,4], '<code>myArray</code> should equal [0,1,2,3,4].');"
"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].');"
],
"challengeSeed":[
"var myArray = [];",
@ -883,9 +883,9 @@
"Use <code>Math.random()</code> to get <code>myFunction</code> to return a random number."
],
"tests":[
"assert(typeof(myFunction()) === \"number\", '<code>myFunction</code> should return a random number.');",
"assert((myFunction()+''). match(/\\./g), 'The number returned by <code>myFunction</code> should be a decimal.');",
"assert(editor.getValue().match(/Math\\.random/g).length >= 2, 'You should be using <code>Math.random</code> to generate the random decimal 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(editor.getValue().match(/Math\\.random/g).length >= 2, 'message: You should be using <code>Math.random</code> to generate the random decimal number.');"
],
"challengeSeed":[
"function myFunction() {",
@ -916,10 +916,10 @@
"Let's give this technique a go now."
],
"tests":[
"assert(typeof(myFunction()) === \"number\", 'The result of <code>myFunction</code> should be a number.');",
"assert(editor.getValue().match(/Math.random/g), 'You should be using Math.random to create a random number.');",
"assert(editor.getValue().match(/\\(\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\*\\s*?10\\s*?\\)/g) || editor.getValue().match(/\\(\\s*?10\\s*?\\*\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\)/g), 'You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that\\'s between zero and nine.');",
"assert(editor.getValue().match(/Math.floor/g), 'You should use <code>Math.floor</code> to remove the decimal part of the number.');"
"assert(typeof(myFunction()) === \"number\", 'message: The result of <code>myFunction</code> should be a number.');",
"assert(editor.getValue().match(/Math.random/g), 'message: You should be using Math.random to create a random number.');",
"assert(editor.getValue().match(/\\(\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\*\\s*?10\\s*?\\)/g) || editor.getValue().match(/\\(\\s*?10\\s*?\\*\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\)/g), 'message: You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that is between zero and nine.');",
"assert(editor.getValue().match(/Math.floor/g), 'message: You should use <code>Math.floor</code> to remove the decimal part of the number.');"
],
"challengeSeed":[
"function myFunction(){",
@ -948,10 +948,10 @@
"By using this, we can control the output of a random number."
],
"tests":[
"assert(myFunction() >= min, 'The random number that\\'s generated by myFunction should be greater than or equal to the minimum number');",
"assert(myFunction() <= max, 'The random number that\\'s generated by myFunction should be less than or equal to the maximum number');",
"assert(myFunction() % 1 === 0 , 'The random number that\\'s generated by myFunction should be an integer');",
"assert((function(){if(editor.getValue().match(/max/g).length >= 2 && editor.getValue().match(/min/g).length >= 2 && editor.getValue().match(/Math.floor/g) && editor.getValue().match(/Math.random/g)){return true;}else{return false;}})(), 'You should be using the function given in the description to calculate the random in number in a range');"
"assert(myFunction() >= min, 'message: The random number generated by <code>myFunction</code> should be greater than or equal to the minimum number.');",
"assert(myFunction() <= max, 'message: The random number generated by <code>myFunction</code> should be less than or equal to the maximum number.');",
"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(/max/g).length >= 2 && editor.getValue().match(/min/g).length >= 2 && editor.getValue().match(/Math.floor/g) && editor.getValue().match(/Math.random/g)){return true;}else{return false;}})(), 'message: You should be using the function given in the description to calculate the random in number in a range.');"
],
"challengeSeed":[
"var min = 0;",
@ -987,10 +987,10 @@
"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":[
"assert((function(){var result = myFunction();if(result === 'heads' || result === 'tails'){return true;} else {return false;}})(), '<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;}})(), '<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, 'You should have created a new if statement.');",
"assert(editor.getValue().match(/else/g).length >= 2, 'You should have 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' && 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":[
"var flip = Math.floor(Math.random() * (1 - 0 + 1)) + 0;",
@ -1025,8 +1025,8 @@
"Let's try selecting all the occurrences of the word <code>and</code> in the string <code>Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it</code>. We can do this by replacing the <code>.</code> part of our regular expression with the current <code>regular expression</code> with the word <code>and</code>."
],
"tests":[
"assert(test==2, 'Your <code>regular expression</code> should find two occurrences of the word <code>and</code>.');",
"assert(editor.getValue().match(/\\/and\\/gi/), 'You should have used <code>regular expressions</code> to find the word <code>and</code>.');"
"assert(test==2, 'message: Your <code>regular expression</code> should find two occurrences of the word <code>and</code>.');",
"assert(editor.getValue().match(/\\/and\\/gi/), 'message: You should have used <code>regular expressions</code> to find the word <code>and</code>.');"
],
"challengeSeed":[
"var test = (function() {",
@ -1056,8 +1056,8 @@
"Use the <code>\\d</code> selector to select the number of numbers in the string, allowing for the possibility of multi-digit numbers."
],
"tests":[
"assert(test === 2, 'Your RegEx should have found two numbers in the <code>testString</code>.');",
"assert(editor.getValue().match(/\\/\\\\d\\+\\//gi), 'You should be using the following expression <code>/\\\\d+/gi</code> to find the numbers in the <code>testString</code>.');"
"assert(test === 2, 'message: Your RegEx should have found two numbers in the <code>testString</code>.');",
"assert(editor.getValue().match(/\\/\\\\d\\+\\//gi), 'message: You should be using the following expression <code>/\\\\d+/gi</code> to find the numbers in the <code>testString</code>.');"
],
"challengeSeed":[
"var test = (function() {",
@ -1086,8 +1086,8 @@
"Select all the spaces in the sentence string."
],
"tests":[
"assert(test === 7, 'Your RegEx should have found seven spaces in the <code>testString</code>.');",
"assert(editor.getValue().match(/\\/\\\\s\\+\\//gi), 'You should be using the following expression <code>/\\\\s+/gi</code> to find the spaces in the <code>testString</code>.');"
"assert(test === 7, 'message: Your RegEx should have found seven spaces in the <code>testString</code>.');",
"assert(editor.getValue().match(/\\/\\\\s\\+\\//gi), 'message: You should be using the following expression <code>/\\\\s+/gi</code> to find the spaces in the <code>testString</code>.');"
],
"challengeSeed":[
"var test = (function(){",
@ -1114,8 +1114,8 @@
"You can invert any match by using the uppercase version of the selector <code>\\s</code> versus <code>\\S</code> for example."
],
"tests":[
"assert(test === 49, 'Your RegEx should have found forty nine non-space characters in the <code>testString</code>.');",
"assert(editor.getValue().match(/\\/\\\\S\\/gi/gi), 'You should be using the following expression <code>/\\\\S/gi</code> to find non-space characters in the <code>testString</code>.');"
"assert(test === 49, 'message: Your RegEx should have found forty nine non-space characters in the <code>testString</code>.');",
"assert(editor.getValue().match(/\\/\\\\S\\/gi/gi), 'message: You should be using the following expression <code>/\\\\S/gi</code> to find non-space characters in the <code>testString</code>.');"
],
"challengeSeed":[
"var test = (function(){",
@ -1145,10 +1145,10 @@
"<code>Math.floor(Math.random() * (3 - 1 + 1)) + 1;</code>"
],
"tests":[
"assert(typeof(runSlots($(\".slot\"))[0]) === \"number\", '<code>slotOne</code> should be a random number.')",
"assert(typeof(runSlots($(\".slot\"))[1]) === \"number\", '<code>slotTwo</code> should be a random number.')",
"assert(typeof(runSlots($(\".slot\"))[2]) === \"number\", '<code>slotThree</code> should be a random number.')",
"assert((function(){if(editor.match(/Math\\.floor\\(\\s?Math\\.random\\(\\)\\s?\\*\\s?\\(\\s?3\\s?\\-\\s?1\\s?\\+\\s?1\\s?\\)\\s?\\)\\s?\\+\\s?1;/gi) !== null){return editor.match(/Math\\.floor\\(\\s?Math\\.random\\(\\)\\s?\\*\\s?\\(\\s?3\\s?\\-\\s?1\\s?\\+\\s?1\\s?\\)\\s?\\)\\s?\\+\\s?1;/gi).length >= 3;}else{return false;}})(), 'You should have used <code>Math.floor(Math.random() * (3 - 1 + 1)) + 1;</code> three times to generate your random numbers.')"
"assert(typeof(runSlots($(\".slot\"))[0]) === \"number\", 'message: <code>slotOne</code> should be a random number.')",
"assert(typeof(runSlots($(\".slot\"))[1]) === \"number\", 'message: <code>slotTwo</code> should be a random number.')",
"assert(typeof(runSlots($(\".slot\"))[2]) === \"number\", 'message: <code>slotThree</code> should be a random number.')",
"assert((function(){if(editor.match(/Math\\.floor\\(\\s?Math\\.random\\(\\)\\s?\\*\\s?\\(\\s?3\\s?\\-\\s?1\\s?\\+\\s?1\\s?\\)\\s?\\)\\s?\\+\\s?1;/gi) !== null){return editor.match(/Math\\.floor\\(\\s?Math\\.random\\(\\)\\s?\\*\\s?\\(\\s?3\\s?\\-\\s?1\\s?\\+\\s?1\\s?\\)\\s?\\)\\s?\\+\\s?1;/gi).length >= 3;}else{return false;}})(), 'message: You should have used <code>Math.floor(Math.random() * (3 - 1 + 1)) + 1;</code> three times to generate your random numbers.')"
],
"challengeSeed":[
"fccss",
@ -1615,7 +1615,7 @@
},
{
"id":"cf1111c1c11feddfaeb1bdff",
"title": "Give your JavaScript Slot Machine some stylish images",
"title": "Give your JavaScript Slot Machine some Stylish Images",
"difficulty":"9.9901",
"description":[
"Now let's add some images to our slots.",

View File

@ -20,9 +20,9 @@
"Give your <code>motorBike</code> object a <code>wheels</code>, <code>engines</code> and <code>seats</code> attribute and set them to numbers."
],
"tests":[
"assert(typeof(motorBike.engines) === 'number', '<code>motorBike</code> should have a <code>engines</code> attribute set to a number.');",
"assert(typeof(motorBike.wheels) === 'number', '<code>motorBike</code> should have a <code>wheels</code> attribute set to a number.');",
"assert(typeof(motorBike.seats) === 'number', '<code>motorBike</code> should have a <code>seats</code> attribute set to a number.');"
"assert(typeof(motorBike.engines) === 'number', 'message: <code>motorBike</code> should have a <code>engines</code> attribute set to a number.');",
"assert(typeof(motorBike.wheels) === 'number', 'message: <code>motorBike</code> should have a <code>wheels</code> attribute set to a number.');",
"assert(typeof(motorBike.seats) === 'number', 'message: <code>motorBike</code> should have a <code>seats</code> attribute set to a number.');"
],
"challengeSeed":[
"//Here is a sample Object",
@ -57,9 +57,9 @@
"Give your <code>myMotorBike</code> object a <code>wheels</code>, <code>engines</code> and <code>seats</code> attribute and set them to numbers."
],
"tests":[
"assert(typeof((new MotorBike()).engines) === 'number', '<code>myMotorBike</code> should have a <code>engines</code> attribute set to a number.');",
"assert(typeof((new MotorBike()).wheels) === 'number', '<code>myMotorBike</code> should have a <code>wheels</code> attribute set to a number.');",
"assert(typeof((new MotorBike()).seats) === 'number', '<code>myMotorBike</code> should have a <code>seats</code> attribute set to a number.');"
"assert(typeof((new MotorBike()).engines) === 'number', 'message: <code>myMotorBike</code> should have a <code>engines</code> attribute set to a number.');",
"assert(typeof((new MotorBike()).wheels) === 'number', 'message: <code>myMotorBike</code> should have a <code>wheels</code> attribute set to a number.');",
"assert(typeof((new MotorBike()).seats) === 'number', 'message: <code>myMotorBike</code> should have a <code>seats</code> attribute set to a number.');"
],
"challengeSeed":[
"// Let's add the properties engines and seats to the car in the same way that the property wheels has been added below. They should both be numbers.",
@ -98,9 +98,9 @@
"See if you can keep <code>myBike.speed</code> and <code>myBike.addUnit</code> private, while making <code>myBike.getSpeed</code> publicly accessible."
],
"tests":[
"assert(typeof(myBike.getSpeed)!=='undefined' && typeof(myBike.getSpeed) === 'function', 'The method getSpeed of myBike should be accessible outside the object');",
"assert(typeof(myBike.speed) === 'undefined', '<code>myBike.speed</code> should remain undefined.');",
"assert(typeof(myBike.addUnit) === 'undefined', '<code>myBike.addUnit</code> should remain undefined.');"
"assert(typeof(myBike.getSpeed)!=='undefined' && typeof(myBike.getSpeed) === 'function', 'message: The method getSpeed of myBike should be accessible outside the object.');",
"assert(typeof(myBike.speed) === 'undefined', 'message: <code>myBike.speed</code> should remain undefined.');",
"assert(typeof(myBike.addUnit) === 'undefined', 'message: <code>myBike.addUnit</code> should remain undefined.');"
],
"challengeSeed":[
"//Let's create an object with a two functions. One attached as a property and one not.",
@ -149,10 +149,10 @@
"Then you can give the instance new properties."
],
"tests":[
"assert((new Car()).wheels === 4, 'The property <code>wheels</code> should still be 4 like in the object constructor');",
"assert(typeof((new Car()).engines) === 'undefined', 'There should not be a property engine in the object constructor');",
"assert(myCar.wheels === 4, 'The property wheels of myCar should be four');",
"assert(typeof(myCar.engines) === 'number', 'The property engine of myCar should be a number');"
"assert((new Car()).wheels === 4, 'message: The property <code>wheels</code> should still be 4 like in the object constructor.');",
"assert(typeof((new Car()).engines) === 'undefined', 'message: There should not be a property <code>engines</code> in the object constructor.');",
"assert(myCar.wheels === 4, 'message: The property <code>wheels</code> of myCar should equal 4.');",
"assert(typeof(myCar.engines) === 'number', 'message: The property <code>engines</code> of myCar should be a number.');"
],
"challengeSeed":[
"var Car = function() {",
@ -184,9 +184,9 @@
"Use the map function to add 3 to every value in the variable <code>array</code>"
],
"tests":[
"assert.deepEqual(array, [4,5,6,7,8], 'You should have added three to each value in the array');",
"assert(editor.getValue().match(/\\.map\\(/gi), 'You should be making use of the map method');",
"assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\]/gi), 'You should only modify the array with .map');"
"assert.deepEqual(array, [4,5,6,7,8], 'message: You should add three to each value in the array.');",
"assert(editor.getValue().match(/\\.map\\(/gi), 'message: You should be making use of the map method.');",
"assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\]/gi), 'message: You should only modify the array with <code>.map</code>.');"
],
"challengeSeed":[
"//Use map to add three to each value in the array",
@ -212,8 +212,8 @@
"<code>});</code>"
],
"tests":[
"assert(singleVal == 30, 'singleVal should have been set to the result of you reduce operation');",
"assert(editor.getValue().match(/\\.reduce\\(/gi), 'You should have made use of the reduce method');"
"assert(singleVal == 30, 'message: <code>singleVal</code> should have been set to the result of you reduce operation.');",
"assert(editor.getValue().match(/\\.reduce\\(/gi), 'message: You should have made use of the reduce method.');"
],
"challengeSeed":[
"var array = [4,5,6,7,8];",
@ -240,9 +240,9 @@
"<code>});</code>"
],
"tests":[
"assert.deepEqual(array, [1,2,3,4,5], 'You should have removed all the values from the array that are greater than five');",
"assert(editor.getValue().match(/array\\.filter\\(/gi), 'You should be using the filter method to remove the values from the array');",
"assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\,6\\,7\\,8\\,9\\,10\\]/gi), 'You should only be using .filter to modify the contents of the array');"
"assert.deepEqual(array, [1,2,3,4], 'message: You should have removed all the values from the array that are greater than 4.');",
"assert(editor.getValue().match(/array\\.filter\\(/gi), 'message: You should be using the filter method to remove the values from the array.');",
"assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\,6\\,7\\,8\\,9\\,10\\]/gi), 'message: You should only be using <code>.filter</code> to modify the contents of the array.');"
],
"challengeSeed":[
"var array = [1,2,3,4,5,6,7,8,9,10];",
@ -267,9 +267,9 @@
"This will return <code>[1, 2, 3]</code>"
],
"tests":[
"assert.deepEqual(array, ['alpha', 'beta', 'charlie'], 'You should have sorted the array alphabetically');",
"assert(editor.getValue().match(/\\[\\'beta\\'\\,\\s\\'alpha\\'\\,\\s'charlie\\'\\];/gi), 'You should be sorting the array using sort');",
"assert(editor.getValue().match(/\\.sort\\(\\)/gi), 'You should have made use of the sort method');"
"assert.deepEqual(array, ['alpha', 'beta', 'charlie'], 'message: You should have sorted the array alphabetically.');",
"assert(editor.getValue().match(/\\[\\'beta\\'\\,\\s\\'alpha\\'\\,\\s'charlie\\'\\];/gi), 'message: You should be sorting the array using sort.');",
"assert(editor.getValue().match(/\\.sort\\(\\)/gi), 'message: You should have made use of the sort method.');"
],
"challengeSeed":[
"var array = ['beta', 'alpha', 'charlie'];",
@ -291,9 +291,9 @@
"You can use the <code>.reverse()</code> function to reverse the contents of an array."
],
"tests": [
"assert.deepEqual(array, [7,6,5,4,3,2,1], 'You should reverse the array');",
"assert(editor.getValue().match(/\\.reverse\\(\\)/gi), '');",
"assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\,6\\,7/gi), '');"
"assert.deepEqual(array, [7,6,5,4,3,2,1], 'message: You should reverse the array.');",
"assert(editor.getValue().match(/\\.reverse\\(\\)/gi), 'message: You should use the reverse method.');",
"assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\,6\\,7/gi), 'message: You should return <code>[7,6,5,4,3,2,1]</code>.');"
],
"challengeSeed": [
"var array = [1,2,3,4,5,6,7];",
@ -316,9 +316,9 @@
"<code>array = array.concat(otherArray);</code>"
],
"tests": [
"assert.deepEqual(array, [1,2,3,4,5,6], 'You should concat the two arrays together');",
"assert(editor.getValue().match(/\\.concat\\(/gi), 'You should be using the concat method to merge the two arrays');",
"assert(editor.getValue().match(/\\[1\\,2\\,3\\]/gi) && editor.getValue().match(/\\[4\\,5\\,6\\]/gi), 'You should only modify the two arrays without changing the origional ones');"
"assert.deepEqual(array, [1,2,3,4,5,6], 'You should concat the two arrays together.');",
"assert(editor.getValue().match(/\\.concat\\(/gi), 'message: You should be use the concat method to merge the two arrays.');",
"assert(editor.getValue().match(/\\[1\\,2\\,3\\]/gi) && editor.getValue().match(/\\[4\\,5\\,6\\]/gi), 'message: You should only modify the two arrays without changing the origional ones.');"
],
"challengeSeed": [
"var array = [1,2,3];",
@ -344,8 +344,8 @@
"<code>array = string.split(' ');</code>"
],
"tests":[
"assert(typeof(array) === 'object' && array.length === 5, 'You should have split the string by it\\'s spaces');",
"assert(/\\.split\\(/gi, 'You should have made use of the split method on the string');"
"assert(typeof(array) === 'object' && array.length === 5, 'message: You should split the string by its spaces.');",
"assert(/\\.split\\(/gi, 'message: You should use the split method on the string.');"
],
"challengeSeed":[
"var string = \"Split me into an array\";",
@ -368,8 +368,8 @@
"<code>var joinMe = joinMe.join(\" \");</code>"
],
"tests":[
"assert(typeof(joinMe) === 'string' && joinMe === \"Split me into an array\", 'You should have joined the arrays by it\\'s spaces');",
"assert(/\\.join\\(/gi, 'You should have made use of the join method on the array');"
"assert(typeof(joinMe) === 'string' && joinMe === \"Split me into an array\", 'message: You should join the arrays by their spaces.');",
"assert(/\\.join\\(/gi, 'message: You should use of the join method on the array.');"
],
"challengeSeed":[
"var joinMe = [\"Split\",\"me\",\"into\",\"an\",\"array\"];",