From eb7aaf4c6428d2d00a747b15e9e7639b56c3f56b Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Wed, 30 Sep 2015 18:33:32 -0700 Subject: [PATCH] fix exact change and QA all JS challenges --- challenges/advanced-bonfires.json | 34 ++-- .../automated-testing-and-debugging.json | 10 +- challenges/basic-javascript.json | 150 +++++++++--------- ...t-oriented-and-functional-programming.json | 68 ++++---- 4 files changed, 131 insertions(+), 131 deletions(-) diff --git a/challenges/advanced-bonfires.json b/challenges/advanced-bonfires.json index dd4b9d37787..48bc294b7b0 100644 --- a/challenges/advanced-bonfires.json +++ b/challenges/advanced-bonfires.json @@ -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: 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]]) 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: 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]]) 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: 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]]) 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: 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]]) should return [['QUARTER', 0.50]].');", - "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: 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]]) should return [['TWENTY', 60.00], ['TEN', 20.00], ['FIVE', 15], ['ONE', 1], ['QUARTER', 0.50], ['DIME', 0.20], ['PENNY', 0.04]].');", - "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: 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]]) 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: 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]]) 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: 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]]) 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: 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]]) 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: 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]]) 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: 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]]) should return [[\"QUARTER\", 0.50]].');", + "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: 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]]) should return [[\"TWENTY\", 60.00], [\"TEN\", 20.00], [\"FIVE\", 15], [\"ONE\", 1], [\"QUARTER\", 0.50], [\"DIME\", 0.20], [\"PENNY\", 0.04]].');", + "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: 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]]) 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: 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]]) should return \"Closed\".');" ], "MDNlinks": [ "Global Object" diff --git a/challenges/automated-testing-and-debugging.json b/challenges/automated-testing-and-debugging.json index 2fbb5352d78..294739a6ca2 100644 --- a/challenges/automated-testing-and-debugging.json +++ b/challenges/automated-testing-and-debugging.json @@ -13,7 +13,7 @@ "console.log('Hello world!')" ], "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 @@ "console.log(typeof({}));" ], "tests":[ - "assert(editor.getValue().match(/console\\.log\\(typeof\\(\"\"\\)\\);/gi), 'You should console.log the typeof a string.');", - "assert(editor.getValue().match(/console\\.log\\(typeof\\(0\\)\\);/gi), 'You should console.log the typeof a number.');", - "assert(editor.getValue().match(/console\\.log\\(typeof\\(\\[\\]\\)\\);/gi), 'You should console.log the typeof an array.');", - "assert(editor.getValue().match(/console\\.log\\(typeof\\(\\{\\}\\)\\);/gi), 'You should console.log the typeof a object.');" + "assert(editor.getValue().match(/console\\.log\\(typeof\\(\"\"\\)\\);/gi), 'message: You should console.log the typeof a string.');", + "assert(editor.getValue().match(/console\\.log\\(typeof\\(0\\)\\);/gi), 'message: You should console.log the typeof a number.');", + "assert(editor.getValue().match(/console\\.log\\(typeof\\(\\[\\]\\)\\);/gi), 'message: You should console.log the typeof an array.');", + "assert(editor.getValue().match(/console\\.log\\(typeof\\(\\{\\}\\)\\);/gi), 'message: You should console.log the typeof a object.');" ], "challengeSeed":[ "", diff --git a/challenges/basic-javascript.json b/challenges/basic-javascript.json index e3542ee41db..95d0884101c 100644 --- a/challenges/basic-javascript.json +++ b/challenges/basic-javascript.json @@ -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 assert() functions (in some challenges except(), assert.equal() 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 // style comment that contains at least five letters');", - "assert(editor.getValue().match(/(\\/\\*)[\\w\\W]{5,}(?=\\*\\/)/gm), 'Create a /* */ style comment that contains at least five letters.');", - "assert(editor.getValue().match(/(\\*\\/)/g), 'Make sure that you close the comment with a */');" + "assert(editor.getValue().match(/(\\/\\/)...../g), 'message: Create a // style comment that contains at least five letters');", + "assert(editor.getValue().match(/(\\/\\*)[\\w\\W]{5,}(?=\\*\\/)/gm), 'message: Create a /* */ style comment that contains at least five letters.');", + "assert(editor.getValue().match(/(\\*\\/)/g), 'message: Make sure that you close the comment with a */');" ], "challengeSeed":[ ], @@ -36,8 +36,8 @@ "Let's modify our welcomeToBooleansfunction so that it will return trueinstead of falsewhen the run button is clicked." ], "tests": [ - "assert(typeof(welcomeToBooleans()) === 'boolean', 'The welcomeToBooleans() function should return a boolean (true/false) value.');", - "assert(welcomeToBooleans() === true, 'welcomeToBooleans() should return true.');" + "assert(typeof(welcomeToBooleans()) === 'boolean', 'message: The welcomeToBooleans() function should return a boolean (true/false) value.');", + "assert(welcomeToBooleans() === true, 'message: welcomeToBooleans() should return true.');" ], "challengeSeed": [ "function welcomeToBooleans() {", @@ -66,7 +66,7 @@ "Look at the ourName example if you get stuck." ], "tests": [ - "assert((function(){if(typeof(myName) !== \"undefined\" && typeof(myName) === \"string\" && myName.length > 0){return true;}else{return false;}})(), 'myName 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: myName 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: myFirstNameand myLastName 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;}})(), 'myFirstName 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;}})(), 'myLastName 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: myFirstName 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: myLastName should be a string with at least one character in it.');" ], "challengeSeed": [ "// var name = \"Alan Turing\";", @@ -117,8 +117,8 @@ "Use the .length property to count the number of characters in the lastName variable." ], "tests": [ - "assert((function(){if(typeof(lastNameLength) !== \"undefined\" && typeof(lastNameLength) === \"number\" && lastNameLength === 8){return true;}else{return false;}})(), 'lastNameLength 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 lastName by using .length like this: lastName.length.');" + "assert((function(){if(typeof(lastNameLength) !== \"undefined\" && typeof(lastNameLength) === \"number\" && lastNameLength === 8){return true;}else{return false;}})(), 'message: lastNameLength 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 lastName by using .length like this: lastName.length.');" ], "challengeSeed": [ "var firstNameLength = 0;", @@ -155,7 +155,7 @@ "Try looking at the firstLetterOfFirstName 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 firstLetterOfLastName should be a \"L\".');" + "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 firstLetterOfLastName should be a \"L\".');" ], "challengeSeed": [ "var firstLetterOfFirstName = \"\";", @@ -189,7 +189,7 @@ "Try looking at the secondLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "assert(thirdLetterOfLastName === 'v', 'The third letter of lastName should be a \"v\".');" + "assert(thirdLetterOfLastName === 'v', 'message: The third letter of lastName should be a \"v\".');" ], "challengeSeed": [ "var firstName = \"Ada\";", @@ -220,8 +220,8 @@ "Try looking at the lastLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "assert(lastLetterOfLastName === \"e\", 'lastLetterOfLastName should be \"e\".');", - "assert(editor.getValue().match(/\\.length/g).length === 2, 'You have to use .length to get the last letter.');" + "assert(lastLetterOfLastName === \"e\", 'message: lastLetterOfLastName should be \"e\".');", + "assert(editor.getValue().match(/\\.length/g).length === 2, 'message: You have to use .length to get the last letter.');" ], "challengeSeed": [ "var firstName = \"Ada\";", @@ -252,8 +252,8 @@ "Try looking at the thirdToLastLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "assert(secondToLastLetterOfLastName === 'c', 'secondToLastLetterOfLastName should be \"c\".');", - "assert(editor.getValue().match(/\\.length/g).length === 2, 'You have to use .length to get the second last letter.');" + "assert(secondToLastLetterOfLastName === 'c', 'message: secondToLastLetterOfLastName should be \"c\".');", + "assert(editor.getValue().match(/\\.length/g).length === 2, 'message: You have to use .length to get the second last letter.');" ], "challengeSeed": [ "var firstName = \"Ada\";", @@ -283,7 +283,7 @@ "Replace the 0 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 sum equal 20.');" + "assert((function(){if(sum === 20 && editor.getValue().match(/\\+/g).length >= 2){return true;}else{return false;}})(), 'message: Make the variable sum 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 0 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 difference equal 12.');" + "assert((function(){if(difference === 12 && editor.getValue().match(/\\-/g)){return true;}else{return false;}})(), 'message: Make the variable difference 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 0 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 product equal 80.');" + "assert((function(){if(product === 80 && editor.getValue().match(/\\*/g)){return true;}else{return false;}})(), 'message: Make the variable product 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 0 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 quotient 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 quotient 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 myDecimal 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: myDecimal should be a decimal point number.');" ], "challengeSeed": [ "// var ourDecimal = 5.7;", @@ -399,8 +399,8 @@ "Replace the 0.0 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 product equal 5.0.');", - "assert((function(){if(quotient === 2.2 && editor.getValue().match(/\\//g)){return true;}else{return false;}})(), 'Make the variable quotient equal 2.2.');" + "assert((function(){if(product === 5.0 && editor.getValue().match(/\\*/g)){return true;}else{return false;}})(), 'message: Make the variable product equal 5.0.');", + "assert((function(){if(quotient === 2.2 && editor.getValue().match(/\\//g)){return true;}else{return false;}})(), 'message: Make the variable quotient 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', 'myArray should be an array.');", - "assert(typeof(myArray[0]) !== 'undefined' && typeof(myArray[0]) == 'string', 'The first item in myArray should be a string.');", - "assert(typeof(myArray[1]) !== 'undefined' && typeof(myArray[1]) == 'number', 'The second item in myArray should be a number.');" + "assert(typeof(myArray) == 'object', 'message: myArray should be an array.');", + "assert(typeof(myArray[0]) !== 'undefined' && typeof(myArray[0]) == 'string', 'message: The first item in myArray should be a string.');", + "assert(typeof(myArray[1]) !== 'undefined' && typeof(myArray[1]) == 'number', 'message: The second item in myArray should be a number.');" ], "challengeSeed": [ "// var array = [\"John\", 23];", @@ -454,7 +454,7 @@ "Let's now go create a nested array called myArray." ], "tests":[ - "assert(Array.isArray(myArray) && myArray.some(Array.isArray), 'myArray should have at least one array nested within another array.');" + "assert(Array.isArray(myArray) && myArray.some(Array.isArray), 'message: myArray 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 myData and set it to equal the first value of myArray." ], "tests":[ - "assert((function(){if(typeof(myArray) != 'undefined' && typeof(myData) != 'undefined' && myArray[0] == myData){return true;}else{return false;}})(), 'The variable myData should equal the first value of myArray.');" + "assert((function(){if(typeof(myArray) != 'undefined' && typeof(myData) != 'undefined' && myArray[0] == myData){return true;}else{return false;}})(), 'message: The variable myData should equal the first value of myArray.');" ], "challengeSeed":[ "// var ourArray = [1,2,3];", @@ -514,8 +514,8 @@ "Now modify the data stored at index 0 of myArray to the value of 3." ], "tests":[ - "assert((function(){if(typeof(myArray) != 'undefined' && myArray[0] == 3 && myArray[1] == 2 && myArray[2] == 3){return true;}else{return false;}})(), 'myArray should now be [3,2,3].');", - "assert((function(){if(editor.getValue().match(/myArray\\[0\\]\\s?=\\s?/g)){return true;}else{return false;}})(), 'You should be using correct index to modify the value in myArray.');" + "assert((function(){if(typeof(myArray) != 'undefined' && myArray[0] == 3 && myArray[1] == 2 && myArray[2] == 3){return true;}else{return false;}})(), 'message: myArray 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 myArray.');" ], "challengeSeed":[ "var ourArray = [1,2,3];", @@ -544,8 +544,8 @@ "Use the .pop() function to remove the last item from myArray." ], "tests": [ - "assert((function(d){if(d[0] == 'John' && d[1] == 23 && d[2] == undefined){return true;}else{return false;}})(myArray), 'myArray should only have the first two values left([\"John\", 23]).');", - "assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return true;}else{return false;}})(removed), 'removed 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: myArray should only contain [\"John\", 23].');", + "assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return true;}else{return false;}})(removed), 'message: removed should only contain [\"cat\"], 2.');" ], "challengeSeed": [ "// var numbers = [1,2,3];", @@ -576,7 +576,7 @@ "Take the myArray array and push() this value to the end of it: [\"dog\", 3]." ], "tests": [ - "assert((function(d){if(d[2] != undefined && d[0] == 'John' && d[1] == 23 && d[2][0] == 'dog' && d[2][1] == 3 && d[2].length == 2){return true;}else{return false;}})(myArray), 'myArray should only have the first two values left([\"John\", 23, [\"dog\", 3]]).');" + "assert((function(d){if(d[2] != undefined && d[0] == 'John' && d[1] == 23 && d[2][0] == 'dog' && d[2][1] == 3 && d[2].length == 2){return true;}else{return false;}})(myArray), 'message: myArray should now equal [\"John\", 23, [\"dog\", 3]].');" ], "challengeSeed": [ "var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];", @@ -607,8 +607,8 @@ "Take the myArray array and shift() the first value off of it. Set myRemoved to the first value of myArray using shift()." ], "tests": [ - "assert((function(d){if(d[0] == 23 && d[1][0] == 'dog' && d[1][1] == 3 && d[2] == undefined){return true;}else{return false;}})(myArray), 'myArray should only have the last two values left([23, [\"dog\", 3]]).');", - "assert((function(d){if(d === 'John' && typeof(myRemoved) === 'string'){return true;}else{return false;}})(myRemoved), 'myRemoved should contain \"John\".');" + "assert((function(d){if(d[0] == 23 && d[1][0] == 'dog' && d[1][1] == 3 && d[2] == undefined){return true;}else{return false;}})(myArray), 'message: myArray should now equal [23, [\"dog\", 3]].');", + "assert((function(d){if(d === 'John' && typeof(myRemoved) === 'string'){return true;}else{return false;}})(myRemoved), 'message: myRemoved should contain \"John\".');" ], "challengeSeed": [ "var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];", @@ -638,7 +638,7 @@ "Let's take the code we had last time and unshiftthis value to the start: \"Paul\"." ], "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), 'myArray 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: myArray should now have [\"Paul\", 23, [\"dog\", 3]]).');" ], "challengeSeed": [ "var ourArray = [\"Stimpson\", \"J\", [\"cat\"]];", @@ -677,7 +677,7 @@ "Create and call a function called myFunction that returns the sum of a and b." ], "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 myDog which contains the properties 'name' (String), 'legs' (Number), 'tails' (Number) and 'friends' (Array)!" ], "tests":[ - "assert((function(z){if(z.hasOwnProperty(\"name\") && z.name !== undefined && typeof(z.name) === \"string\"){return true;}else{return false;}})(myDog), 'myDog should contain the property name and it should be a string.');", - "assert((function(z){if(z.hasOwnProperty(\"legs\") && z.legs !== undefined && typeof(z.legs) === \"number\"){return true;}else{return false;}})(myDog), 'myDog should contain the property legs and it should be a number.');", - "assert((function(z){if(z.hasOwnProperty(\"tails\") && z.tails !== undefined && typeof(z.tails) === \"number\"){return true;}else{return false;}})(myDog), 'myDog should contain the property tails and it should be a number.');", - "assert((function(z){if(z.hasOwnProperty(\"friends\") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), 'myDog should contain the property friends and it should be an array.');" + "assert((function(z){if(z.hasOwnProperty(\"name\") && z.name !== undefined && typeof(z.name) === \"string\"){return true;}else{return false;}})(myDog), 'message: myDog should contain the property name and it should be a string.');", + "assert((function(z){if(z.hasOwnProperty(\"legs\") && z.legs !== undefined && typeof(z.legs) === \"number\"){return true;}else{return false;}})(myDog), 'message: myDog should contain the property legs and it should be a number.');", + "assert((function(z){if(z.hasOwnProperty(\"tails\") && z.tails !== undefined && typeof(z.tails) === \"number\"){return true;}else{return false;}})(myDog), 'message: myDog should contain the property tails and it should be a number.');", + "assert((function(z){if(z.hasOwnProperty(\"friends\") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), 'message: myDog should contain the property friends and it should be an array.');" ], "challengeSeed":[ "// var ourDog = {", @@ -765,8 +765,8 @@ "Let's add the property \"bark\", and delete the property \"tails\"." ], "tests":[ - "assert(myDog.bark !== undefined, 'Add the property \"bark\" to myDog.');", - "assert(myDog.tails === undefined, 'Delete the property \"tails\" from myDog.');" + "assert(myDog.bark !== undefined, 'message: Add the property \"bark\" to myDog.');", + "assert(myDog.tails === undefined, 'message: Delete the property \"tails\" from myDog.');" ], "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 for loop for this.');", - "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4].');" + "assert(editor.getValue().match(/for/g), 'message: You should be using a for loop for this.');", + "assert.deepEqual(myArray, [0,1,2,3,4], 'message: myArray 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 while loop for this.');", - "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4].');" + "assert(editor.getValue().match(/while/g), 'message: You should be using a while loop for this.');", + "assert.deepEqual(myArray, [0,1,2,3,4], 'message: myArray should equal [0,1,2,3,4].');" ], "challengeSeed":[ "var myArray = [];", @@ -883,9 +883,9 @@ "Use Math.random() to get myFunction to return a random number." ], "tests":[ - "assert(typeof(myFunction()) === \"number\", 'myFunction should return a random number.');", - "assert((myFunction()+''). match(/\\./g), 'The number returned by myFunction should be a decimal.');", - "assert(editor.getValue().match(/Math\\.random/g).length >= 2, 'You should be using Math.random to generate the random decimal number.');" + "assert(typeof(myFunction()) === \"number\", 'message: myFunction should return a random number.');", + "assert((myFunction()+''). match(/\\./g), 'message: The number returned by myFunction should be a decimal.');", + "assert(editor.getValue().match(/Math\\.random/g).length >= 2, 'message: You should be using Math.random 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 myFunction 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 Math.random by 10 to make it a number that\\'s between zero and nine.');", - "assert(editor.getValue().match(/Math.floor/g), 'You should use Math.floor to remove the decimal part of the number.');" + "assert(typeof(myFunction()) === \"number\", 'message: The result of myFunction 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 Math.random by 10 to make it a number that is between zero and nine.');", + "assert(editor.getValue().match(/Math.floor/g), 'message: You should use Math.floor 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 myFunction should be greater than or equal to the minimum number.');", + "assert(myFunction() <= max, 'message: The random number generated by myFunction should be less than or equal to the maximum number.');", + "assert(myFunction() % 1 === 0 , 'message: The random number generated by myFunction 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 if and else statements to return the string \"heads\" if the flip variable is zero, or else return the string \"tails\" if the flip variable is not zero." ], "tests":[ - "assert((function(){var result = myFunction();if(result === 'heads' || result === 'tails'){return true;} else {return false;}})(), 'myFunction should either return heads or tails.');", - "assert((function(){var result = myFunction();if(result === 'heads' && flip === 0 || result === 'tails' && flip !== 0){return true;} else {return false;}})(), 'myFunction should return heads when flip equals 0 and tails 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: myFunction should either return heads or tails.');", + "assert((function(){var result = myFunction();if(result === 'heads' && flip === 0 || result === 'tails' && flip !== 0){return true;} else {return false;}})(), 'message: myFunction should return heads when flip equals 0 and tails 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 and in the string Ada Lovelace and Charles Babbage designed the first computer and the software that would have run on it. We can do this by replacing the . part of our regular expression with the current regular expression with the word and." ], "tests":[ - "assert(test==2, 'Your regular expression should find two occurrences of the word and.');", - "assert(editor.getValue().match(/\\/and\\/gi/), 'You should have used regular expressions to find the word and.');" + "assert(test==2, 'message: Your regular expression should find two occurrences of the word and.');", + "assert(editor.getValue().match(/\\/and\\/gi/), 'message: You should have used regular expressions to find the word and.');" ], "challengeSeed":[ "var test = (function() {", @@ -1056,8 +1056,8 @@ "Use the \\d 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 testString.');", - "assert(editor.getValue().match(/\\/\\\\d\\+\\//gi), 'You should be using the following expression /\\\\d+/gi to find the numbers in the testString.');" + "assert(test === 2, 'message: Your RegEx should have found two numbers in the testString.');", + "assert(editor.getValue().match(/\\/\\\\d\\+\\//gi), 'message: You should be using the following expression /\\\\d+/gi to find the numbers in the testString.');" ], "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 testString.');", - "assert(editor.getValue().match(/\\/\\\\s\\+\\//gi), 'You should be using the following expression /\\\\s+/gi to find the spaces in the testString.');" + "assert(test === 7, 'message: Your RegEx should have found seven spaces in the testString.');", + "assert(editor.getValue().match(/\\/\\\\s\\+\\//gi), 'message: You should be using the following expression /\\\\s+/gi to find the spaces in the testString.');" ], "challengeSeed":[ "var test = (function(){", @@ -1114,8 +1114,8 @@ "You can invert any match by using the uppercase version of the selector \\s versus \\S for example." ], "tests":[ - "assert(test === 49, 'Your RegEx should have found forty nine non-space characters in the testString.');", - "assert(editor.getValue().match(/\\/\\\\S\\/gi/gi), 'You should be using the following expression /\\\\S/gi to find non-space characters in the testString.');" + "assert(test === 49, 'message: Your RegEx should have found forty nine non-space characters in the testString.');", + "assert(editor.getValue().match(/\\/\\\\S\\/gi/gi), 'message: You should be using the following expression /\\\\S/gi to find non-space characters in the testString.');" ], "challengeSeed":[ "var test = (function(){", @@ -1145,10 +1145,10 @@ "Math.floor(Math.random() * (3 - 1 + 1)) + 1;" ], "tests":[ - "assert(typeof(runSlots($(\".slot\"))[0]) === \"number\", 'slotOne should be a random number.')", - "assert(typeof(runSlots($(\".slot\"))[1]) === \"number\", 'slotTwo should be a random number.')", - "assert(typeof(runSlots($(\".slot\"))[2]) === \"number\", 'slotThree 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 Math.floor(Math.random() * (3 - 1 + 1)) + 1; three times to generate your random numbers.')" + "assert(typeof(runSlots($(\".slot\"))[0]) === \"number\", 'message: slotOne should be a random number.')", + "assert(typeof(runSlots($(\".slot\"))[1]) === \"number\", 'message: slotTwo should be a random number.')", + "assert(typeof(runSlots($(\".slot\"))[2]) === \"number\", 'message: slotThree 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 Math.floor(Math.random() * (3 - 1 + 1)) + 1; 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.", diff --git a/challenges/object-oriented-and-functional-programming.json b/challenges/object-oriented-and-functional-programming.json index 2b89e9f6c0b..ea84d904db0 100644 --- a/challenges/object-oriented-and-functional-programming.json +++ b/challenges/object-oriented-and-functional-programming.json @@ -20,9 +20,9 @@ "Give your motorBike object a wheels, engines and seats attribute and set them to numbers." ], "tests":[ - "assert(typeof(motorBike.engines) === 'number', 'motorBike should have a engines attribute set to a number.');", - "assert(typeof(motorBike.wheels) === 'number', 'motorBike should have a wheels attribute set to a number.');", - "assert(typeof(motorBike.seats) === 'number', 'motorBike should have a seats attribute set to a number.');" + "assert(typeof(motorBike.engines) === 'number', 'message: motorBike should have a engines attribute set to a number.');", + "assert(typeof(motorBike.wheels) === 'number', 'message: motorBike should have a wheels attribute set to a number.');", + "assert(typeof(motorBike.seats) === 'number', 'message: motorBike should have a seats attribute set to a number.');" ], "challengeSeed":[ "//Here is a sample Object", @@ -57,9 +57,9 @@ "Give your myMotorBike object a wheels, engines and seats attribute and set them to numbers." ], "tests":[ - "assert(typeof((new MotorBike()).engines) === 'number', 'myMotorBike should have a engines attribute set to a number.');", - "assert(typeof((new MotorBike()).wheels) === 'number', 'myMotorBike should have a wheels attribute set to a number.');", - "assert(typeof((new MotorBike()).seats) === 'number', 'myMotorBike should have a seats attribute set to a number.');" + "assert(typeof((new MotorBike()).engines) === 'number', 'message: myMotorBike should have a engines attribute set to a number.');", + "assert(typeof((new MotorBike()).wheels) === 'number', 'message: myMotorBike should have a wheels attribute set to a number.');", + "assert(typeof((new MotorBike()).seats) === 'number', 'message: myMotorBike should have a seats 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 myBike.speed and myBike.addUnit private, while making myBike.getSpeed 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', 'myBike.speed should remain undefined.');", - "assert(typeof(myBike.addUnit) === 'undefined', 'myBike.addUnit 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: myBike.speed should remain undefined.');", + "assert(typeof(myBike.addUnit) === 'undefined', 'message: myBike.addUnit 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 wheels 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 wheels should still be 4 like in the object constructor.');", + "assert(typeof((new Car()).engines) === 'undefined', 'message: There should not be a property engines in the object constructor.');", + "assert(myCar.wheels === 4, 'message: The property wheels of myCar should equal 4.');", + "assert(typeof(myCar.engines) === 'number', 'message: The property engines 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 array" ], "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 .map.');" ], "challengeSeed":[ "//Use map to add three to each value in the array", @@ -212,8 +212,8 @@ "});" ], "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: singleVal 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 @@ "});" ], "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 .filter 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 [1, 2, 3]" ], "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 .reverse() 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 [7,6,5,4,3,2,1].');" ], "challengeSeed": [ "var array = [1,2,3,4,5,6,7];", @@ -316,9 +316,9 @@ "array = array.concat(otherArray);" ], "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 @@ "array = string.split(' ');" ], "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 @@ "var joinMe = joinMe.join(\" \");" ], "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\"];",