diff --git a/challenges/advanced-bonfires.json b/challenges/advanced-bonfires.json index e7cd4030d4..3ee8a9f041 100644 --- a/challenges/advanced-bonfires.json +++ b/challenges/advanced-bonfires.json @@ -9,33 +9,38 @@ "description": [ "Return true if the passed string is a valid US phone number", "The user may fill out the form field any way they choose as long as it is a valid US number. The following are all valid formats for US numbers:", - "555-555-5555, (555)555-5555, (555) 555-5555, 555 555 5555, 5555555555, 1 555 555 5555", - "For this challenge you will be presented with a string such as \"800-692-7753\" or \"8oo-six427676;laskdjf\". Your job is to validate or reject the US phone number based on any combination of the formats provided above. The area code is required. If the country code is provided, you must confirm that the country code is \"1\". Return true if the string is a valid US phone number; otherwise false.", + "555-555-5555", + "(555)555-5555", + "(555) 555-5555", + "555 555 5555", + "5555555555", + "1 555 555 5555", + "For this challenge you will be presented with a string such as 800-692-7753 or 8oo-six427676;laskdjf. Your job is to validate or reject the US phone number based on any combination of the formats provided above. The area code is required. If the country code is provided, you must confirm that the country code is 1. Return true if the string is a valid US phone number; otherwise false.", "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code." ], "tests": [ - "assert.isBoolean(telephoneCheck(\"555-555-5555\"), 'should return a boolean.');", - "assert.deepEqual(telephoneCheck(\"1 555-555-5555\"), true);", - "assert.deepEqual(telephoneCheck(\"1 (555) 555-5555\"), true);", - "assert.deepEqual(telephoneCheck(\"5555555555\"), true);", - "assert.deepEqual(telephoneCheck(\"555-555-5555\"), true);", - "assert.deepEqual(telephoneCheck(\"(555)555-5555\"), true);", - "assert.deepEqual(telephoneCheck(\"1(555)555-5555\"), true);", - "assert.deepEqual(telephoneCheck(\"1 555 555 5555\"), true);", - "assert.deepEqual(telephoneCheck(\"555-555-5555\"), true);", - "assert.deepEqual(telephoneCheck(\"1 456 789 4444\"), true);", - "assert.deepEqual(telephoneCheck(\"123**&!!asdf#\"), false);", - "assert.deepEqual(telephoneCheck(\"55555555\"), false);", - "assert.deepEqual(telephoneCheck(\"(6505552368)\"), false);", - "assert.deepEqual(telephoneCheck(\"2 (757) 622-7382\"), false);", - "assert.deepEqual(telephoneCheck(\"0 (757) 622-7382\"), false);", - "assert.deepEqual(telephoneCheck(\"-1 (757) 622-7382\"), false);", - "assert.deepEqual(telephoneCheck(\"2 757 622-7382\"), false);", - "assert.deepEqual(telephoneCheck(\"10 (757) 622-7382\"), false);", - "assert.deepEqual(telephoneCheck(\"27576227382\"), false);", - "assert.deepEqual(telephoneCheck(\"(275)76227382\"), false);", - "assert.deepEqual(telephoneCheck(\"2(757)6227382\"), false);", - "assert.deepEqual(telephoneCheck(\"2(757)622-7382\"), false);" + "assert.isBoolean(telephoneCheck(\"555-555-5555\"), 'message: should return a boolean.');", + "assert(telephoneCheck(\"1 555-555-5555\") === true, 'message: telephoneCheck(\"1 555-555-5555\") should return true.');", + "assert(telephoneCheck(\"1 (555) 555-5555\") === true, 'message: telephoneCheck(\"1 (555) 555-5555\") should return true.');", + "assert(telephoneCheck(\"5555555555\") === true, 'message: telephoneCheck(\"5555555555\") should return true.');", + "assert(telephoneCheck(\"555-555-5555\") === true, 'message: telephoneCheck(\"555-555-5555\") should return true.');", + "assert(telephoneCheck(\"(555)555-5555\") === true, 'message: telephoneCheck(\"(555)555-5555\") should return true.');", + "assert(telephoneCheck(\"1(555)555-5555\") === true, 'message: telephoneCheck(\"1(555)555-5555\") should return true.');", + "assert(telephoneCheck(\"1 555 555 5555\") === true, 'message: telephoneCheck(\"1 555 555 5555\") should return true.');", + "assert(telephoneCheck(\"555-555-5555\") === true, 'message: telephoneCheck(\"555-555-5555\") should return true.');", + "assert(telephoneCheck(\"1 456 789 4444\") === true, 'message: telephoneCheck(\"1 456 789 4444\") should return true.');", + "assert(telephoneCheck(\"123**&!!asdf#\") === false, 'message: telephoneCheck(\"123**&!!asdf#\") should return false.');", + "assert(telephoneCheck(\"55555555\") === false, 'message: telephoneCheck(\"55555555\") should return false.');", + "assert(telephoneCheck(\"(6505552368)\") === false, 'message: telephoneCheck(\"(6505552368)\") should return false');", + "assert(telephoneCheck(\"2 (757) 622-7382\") === false, 'message: telephoneCheck(\"2 (757) 622-7382\") should return false.');", + "assert(telephoneCheck(\"0 (757) 622-7382\") === false, 'message: telephoneCheck(\"0 (757) 622-7382\") should return false.');", + "assert(telephoneCheck(\"-1 (757) 622-7382\") === false, 'message: telephoneCheck(\"-1 (757) 622-7382\") should return false');", + "assert(telephoneCheck(\"2 757 622-7382\") === false, 'message: telephoneCheck(\"2 757 622-7382\") should return false.');", + "assert(telephoneCheck(\"10 (757) 622-7382\") === false, 'message: telephoneCheck(\"10 (757) 622-7382\") should return false.');", + "assert(telephoneCheck(\"27576227382\") === false, 'message: telephoneCheck(\"27576227382\") should return false.');", + "assert(telephoneCheck(\"(275)76227382\") === false, 'message: telephoneCheck(\"(275)76227382\") should return false.');", + "assert(telephoneCheck(\"2(757)6227382\") === false, 'message: telephoneCheck(\"2(757)6227382\") should return false.');", + "assert(telephoneCheck(\"2(757)622-7382\") === false, 'message: telephoneCheck(\"2(757)622-7382\") should return false.');" ], "challengeSeed": [ "function telephoneCheck(str) {", @@ -74,16 +79,16 @@ ], "challengeSeed": [ "function sym(args) {", - " return arguments;", + " return args;", "}", "", "sym([1, 2, 3], [5, 2, 1, 4]);" ], "tests": [ - "assert.sameMembers(sym([1, 2, 3], [5, 2, 1, 4]), [3, 5, 4], 'should return an array of unique values');", - "assert.sameMembers(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5], 'should return the symmetric difference of the given arrays');", - "assert.sameMembers(sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]), [1, 4, 5], 'should return an array of unique values');", - "assert.sameMembers(sym([1, 1]), [1], 'should return an array of unique values');" + "assert.sameMembers(sym([1, 2, 3], [5, 2, 1, 4]), [3, 5, 4], 'message: sym([1, 2, 3], [5, 2, 1, 4]) should return [3, 5, 4].');", + "assert.sameMembers(sym([1, 2, 5], [2, 3, 5], [3, 4, 5]), [1, 4, 5], 'message: sym([1, 2, 5], [2, 3, 5], [3, 4, 5]) should return [1, 4, 5]');", + "assert.sameMembers(sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]), [1, 4, 5], 'message: sym([1, 1, 2, 5], [2, 2, 3, 5], [3, 4, 5, 5]) should return [1, 4, 5].');", + "assert.sameMembers(sym([1, 1]), [1], 'message: sym([1, 1]) should return [1].');" ], "MDNlinks": [ "Array.reduce()", @@ -121,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]]), '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]]), '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]]), '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]], 'return correct change');", - "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] ], 'return correct change with multiple coins and bills');", - "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', '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\", 'cash-in-drawer equals change');" + "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" @@ -174,28 +179,28 @@ "", "// Example inventory lists", "var curInv = [", - " [21, 'Bowling Ball'],", - " [2, 'Dirty Sock'],", - " [1, 'Hair Pin'],", - " [5, 'Microphone']", + " [21, \"Bowling Ball\"],", + " [2, \"Dirty Sock\"],", + " [1, \"Hair Pin\"],", + " [5, \"Microphone\"]", "];", "", "var newInv = [", - " [2, 'Hair Pin'],", - " [3, 'Half-Eaten Apple'],", - " [67, 'Bowling Ball'],", - " [7, 'Toothpaste']", + " [2, \"Hair Pin\"],", + " [3, \"Half-Eaten Apple\"],", + " [67, \"Bowling Ball\"],", + " [7, \"Toothpaste\"]", "];", "", "inventory(curInv, newInv);" ], "tests": [ - "assert.isArray(inventory([[21, 'Bowling Ball'], [2, 'Dirty Sock'], [1, 'Hair Pin'], [5, 'Microphone']], [[2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [67, 'Bowling Ball'], [7, 'Toothpaste']]), 'should return an array.');", - "assert.equal(inventory([[21, 'Bowling Ball'], [2, 'Dirty Sock'], [1, 'Hair Pin'], [5, 'Microphone']], [[2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [67, 'Bowling Ball'], [7, 'Toothpaste']]).length, 6, 'should return an array with a length of 6.');", - "assert.deepEqual(inventory([[21, 'Bowling Ball'], [2, 'Dirty Sock'], [1, 'Hair Pin'], [5, 'Microphone']], [[2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [67, 'Bowling Ball'], [7, 'Toothpaste']]), [[88, 'Bowling Ball'], [2, 'Dirty Sock'], [3, 'Hair Pin'], [3, 'Half-Eaten Apple'], [5, 'Microphone'], [7, 'Toothpaste']]);", - "assert.deepEqual(inventory([[21, 'Bowling Ball'], [2, 'Dirty Sock'], [1, 'Hair Pin'], [5, 'Microphone']], []), [[21, 'Bowling Ball'], [2, 'Dirty Sock'], [1, 'Hair Pin'], [5, 'Microphone']]);", - "assert.deepEqual(inventory([], [[2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [67, 'Bowling Ball'], [7, 'Toothpaste']]), [[67, 'Bowling Ball'], [2, 'Hair Pin'], [3, 'Half-Eaten Apple'], [7, 'Toothpaste']]);", - "assert.deepEqual(inventory([[0, 'Bowling Ball'], [0, 'Dirty Sock'], [0, 'Hair Pin'], [0, 'Microphone']], [[1, 'Hair Pin'], [1, 'Half-Eaten Apple'], [1, 'Bowling Ball'], [1, 'Toothpaste']]), [[1, 'Bowling Ball'], [0, 'Dirty Sock'], [1, 'Hair Pin'], [1, 'Half-Eaten Apple'], [0, 'Microphone'], [1, 'Toothpaste']]);" + "assert.isArray(inventory([[21, \"Bowling Ball\"], [2, \"Dirty Sock\"], [1, \"Hair Pin\"], [5, \"Microphone\"]], [[2, \"Hair Pin\"], [3, \"Half-Eaten Apple\"], [67, \"Bowling Ball\"], [7, \"Toothpaste\"]]), 'message: inventory() should return an array.');", + "assert.equal(inventory([[21, \"Bowling Ball\"], [2, \"Dirty Sock\"], [1, \"Hair Pin\"], [5, \"Microphone\"]], [[2, \"Hair Pin\"], [3, \"Half-Eaten Apple\"], [67, \"Bowling Ball\"], [7, \"Toothpaste\"]]).length, 6, 'message: inventory([[21, \"Bowling Ball\"], [2, \"Dirty Sock\"], [1, \"Hair Pin\"], [5, \"Microphone\"]], [[2, \"Hair Pin\"], [3, \"Half-Eaten Apple\"], [67, \"Bowling Ball\"], [7, \"Toothpaste\"]]).length should return an array with a length of 6.');", + "assert.deepEqual(inventory([[21, \"Bowling Ball\"], [2, \"Dirty Sock\"], [1, \"Hair Pin\"], [5, \"Microphone\"]], [[2, \"Hair Pin\"], [3, \"Half-Eaten Apple\"], [67, \"Bowling Ball\"], [7, \"Toothpaste\"]]), [[88, \"Bowling Ball\"], [2, \"Dirty Sock\"], [3, \"Hair Pin\"], [3, \"Half-Eaten Apple\"], [5, \"Microphone\"], [7, \"Toothpaste\"]], 'message: inventory([[21, \"Bowling Ball\"], [2, \"Dirty Sock\"], [1, \"Hair Pin\"], [5, \"Microphone\"]], [[2, \"Hair Pin\"], [3, \"Half-Eaten Apple\"], [67, \"Bowling Ball\"], [7, \"Toothpaste\"]]) should return [[88, \"Bowling Ball\"], [2, \"Dirty Sock\"], [3, \"Hair Pin\"], [3, \"Half-Eaten Apple\"], [5, \"Microphone\"], [7, \"Toothpaste\"]].');", + "assert.deepEqual(inventory([[21, \"Bowling Ball\"], [2, \"Dirty Sock\"], [1, \"Hair Pin\"], [5, \"Microphone\"]], []), [[21, \"Bowling Ball\"], [2, \"Dirty Sock\"], [1, \"Hair Pin\"], [5, \"Microphone\"]], 'message: inventory([[21, \"Bowling Ball\"], [2, \"Dirty Sock\"], [1, \"Hair Pin\"], [5, \"Microphone\"]], []) should return [[21, \"Bowling Ball\"], [2, \"Dirty Sock\"], [1, \"Hair Pin\"], [5, \"Microphone\"]].');", + "assert.deepEqual(inventory([], [[2, \"Hair Pin\"], [3, \"Half-Eaten Apple\"], [67, \"Bowling Ball\"], [7, \"Toothpaste\"]]), [[67, \"Bowling Ball\"], [2, \"Hair Pin\"], [3, \"Half-Eaten Apple\"], [7, \"Toothpaste\"]], 'message: inventory([], [[2, \"Hair Pin\"], [3, \"Half-Eaten Apple\"], [67, \"Bowling Ball\"], [7, \"Toothpaste\"]]) should return [[67, \"Bowling Ball\"], [2, \"Hair Pin\"], [3, \"Half-Eaten Apple\"], [7, \"Toothpaste\"]].');", + "assert.deepEqual(inventory([[0, \"Bowling Ball\"], [0, \"Dirty Sock\"], [0, \"Hair Pin\"], [0, \"Microphone\"]], [[1, \"Hair Pin\"], [1, \"Half-Eaten Apple\"], [1, \"Bowling Ball\"], [1, \"Toothpaste\"]]), [[1, \"Bowling Ball\"], [0, \"Dirty Sock\"], [1, \"Hair Pin\"], [1, \"Half-Eaten Apple\"], [0, \"Microphone\"], [1, \"Toothpaste\"]], 'message: inventory([[0, \"Bowling Ball\"], [0, \"Dirty Sock\"], [0, \"Hair Pin\"], [0, \"Microphone\"]], [[1, \"Hair Pin\"], [1, \"Half-Eaten Apple\"], [1, \"Bowling Ball\"], [1, \"Toothpaste\"]]) should return [[1, \"Bowling Ball\"], [0, \"Dirty Sock\"], [1, \"Hair Pin\"], [1, \"Half-Eaten Apple\"], [0, \"Microphone\"], [1, \"Toothpaste\"]].');" ], "MDNlinks": [ "Global Array Object" @@ -230,13 +235,13 @@ "permAlone('aab');" ], "tests": [ - "assert.isNumber(permAlone('aab'), 'should return a \"number\".');", - "assert.strictEqual(permAlone('aab'), 2, 'should return 2.');", - "assert.strictEqual(permAlone('aaa'), 0, 'should return 0.');", - "assert.strictEqual(permAlone('aabb'), 8, 'should return 8.');", - "assert.strictEqual(permAlone('abcdefa'), 3600, 'should return 3600.');", - "assert.strictEqual(permAlone('abfdefa'), 2640, 'should return 2640.');", - "assert.strictEqual(permAlone('zzzzzzzz'), 0, 'should return 0.');" + "assert.isNumber(permAlone('aab'), 'message: permAlone() should return a number.');", + "assert.strictEqual(permAlone('aab'), 2, 'message: permAlone(aab) should return 2.');", + "assert.strictEqual(permAlone('aaa'), 0, 'message: permAlone(aaa) should return 0.');", + "assert.strictEqual(permAlone('aabb'), 8, 'message: permAlone(aabb) should return 8.');", + "assert.strictEqual(permAlone('abcdefa'), 3600, 'message: permAlone(abcdefa) should return 3600.');", + "assert.strictEqual(permAlone('abfdefa'), 2640, 'message: permAlone(abfdefa) should return 2640.');", + "assert.strictEqual(permAlone('zzzzzzzz'), 0, 'message: permAlone(zzzzzzzz) should return 0.');" ], "MDNlinks": [ "Permutations", @@ -276,12 +281,12 @@ "friendly(['2015-07-01', '2015-07-04']);" ], "tests": [ - "assert.deepEqual(friendly(['2015-07-01', '2015-07-04']), ['July 1st','4th'], 'ending month should be omitted since it is already mentioned');", - "assert.deepEqual(friendly(['2015-12-01', '2016-02-03']), ['December 1st','February 3rd'], 'two months apart can be inferred if it is the next year');", - "assert.deepEqual(friendly(['2015-12-01', '2017-02-03']), ['December 1st, 2015','February 3rd, 2017']);", - "assert.deepEqual(friendly(['2016-03-01', '2016-05-05']), ['March 1st','May 5th'], 'one month apart can be inferred it is the same year');", - "assert.deepEqual(friendly(['2017-01-01', '2017-01-01']), ['January 1st, 2017'], 'since we do not duplicate only return once');", - "assert.deepEqual(friendly(['2022-09-05', '2023-09-04']), ['September 5th, 2022','September 4th, 2023']);" + "assert.deepEqual(friendly(['2015-07-01', '2015-07-04']), ['July 1st','4th'], 'message: friendly([\"2015-07-01\", \"2015-07-04\"]) should return [\"July 1st\",\"4th\"].');", + "assert.deepEqual(friendly(['2015-12-01', '2016-02-03']), ['December 1st','February 3rd'], 'message: friendly([\"2015-12-01\", \"2016-02-03\"]) should return [\"December 1st\",\"February 3rd\"].');", + "assert.deepEqual(friendly(['2015-12-01', '2017-02-03']), ['December 1st, 2015','February 3rd, 2017'], 'message: friendly([\"2015-12-01\", \"2017-02-03\"]) should return [\"December 1st, 2015\",\"February 3rd, 2017\"].');", + "assert.deepEqual(friendly(['2016-03-01', '2016-05-05']), ['March 1st','May 5th'], 'message: friendly([\"2016-03-01\", \"2016-05-05\"]) should return [\"March 1st\",\"May 5th\"]');", + "assert.deepEqual(friendly(['2017-01-01', '2017-01-01']), ['January 1st, 2017'], 'message: friendly([\"2017-01-01\", \"2017-01-01\"]) should return [\"January 1st, 2017\"].');", + "assert.deepEqual(friendly(['2022-09-05', '2023-09-04']), ['September 5th, 2022','September 4th, 2023'], 'message: friendly([\"2022-09-05\", \"2023-09-04\"]) should return [\"September 5th, 2022\",\"September 4th, 2023\"].');" ], "MDNlinks": [ "String.split()", diff --git a/challenges/automated-testing-and-debugging.json b/challenges/automated-testing-and-debugging.json index 2fbb5352d7..294739a6ca 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-bonfires.json b/challenges/basic-bonfires.json index 34c4c809ad..88a8dbb87a 100644 --- a/challenges/basic-bonfires.json +++ b/challenges/basic-bonfires.json @@ -13,8 +13,8 @@ "Make this function return true no matter what." ], "tests": [ - "assert(typeof(meetBonfire()) === \"boolean\", 'The result should be a Boolean value of true or false.');", - "assert(meetBonfire() === true, 'Your meetBonfire() function should return true.');" + "assert(typeof(meetBonfire()) === \"boolean\", 'message: meetBonfire() should return a boolean value.');", + "assert(meetBonfire() === true, 'message: meetBonfire() should return true.');" ], "challengeSeed": [ "function meetBonfire(argument) {", @@ -46,10 +46,10 @@ "title": "Reverse a String", "difficulty": "1.01", "tests": [ - "assert(typeof(reverseString(\"hello\")) === \"string\", 'reverseString() should return a string.');", - "assert(reverseString(\"hello\") === \"olleh\", '\"hello\" should become \"olleh\".');", - "assert(reverseString(\"Howdy\") === \"ydwoH\", '\"Howdy\" should become \"ydwoH\".');", - "assert(reverseString(\"Greetings from Earth\") === \"htraE morf sgniteerG\", '\"Greetings from Earth\" should return \"htraE morf sgniteerG\".');" + "assert(typeof(reverseString(\"hello\")) === \"string\", 'message: reverseString() should return a string.');", + "assert(reverseString(\"hello\") === \"olleh\", 'message: reverseString(\"hello\") should become \"olleh\".');", + "assert(reverseString(\"Howdy\") === \"ydwoH\", 'message: reverseString(\"Howdy\") should become \"ydwoH\".');", + "assert(reverseString(\"Greetings from Earth\") === \"htraE morf sgniteerG\", 'message: reverseString(\"Greetings from Earth\") should return \"htraE morf sgniteerG\".');" ], "description": [ "Reverse the provided string.", @@ -87,11 +87,11 @@ "id": "a302f7aae1aa3152a5b413bc", "title": "Factorialize a Number", "tests": [ - "assert(typeof(factorialize(5)) === \"number\", 'factorialize() should return a number.');", - "assert(factorialize(5) === 120, '5 should return 120.');", - "assert(factorialize(10) === 3628800, '10 should return 3,628,800.');", - "assert(factorialize(20) === 2432902008176640000, '20 should return 2,432,902,008,176,640,000.');", - "assert(factorialize(0) === 1, '0 should return 1.');" + "assert(typeof(factorialize(5)) === \"number\", 'message: factorialize() should return a number.');", + "assert(factorialize(5) === 120, 'message: factorialize(5) should return 120.');", + "assert(factorialize(10) === 3628800, 'message: factorialize(10) should return 3628800.');", + "assert(factorialize(20) === 2432902008176640000, 'message: factorialize(20) should return 2432902008176640000.');", + "assert(factorialize(0) === 1, 'message: factorialize(0) should return 1.');" ], "difficulty": "1.02", "description": [ @@ -136,17 +136,17 @@ "Remember to use Read-Search-Ask if you get stuck. Write your own code." ], "tests": [ - "assert(typeof(palindrome(\"eye\")) === \"boolean\", 'palindrome() should return a boolean.');", - "assert(palindrome(\"eye\") === true, '\"eye\" should return true.');", - "assert(palindrome(\"race car\") === true, '\"race car\" should return true.');", - "assert(palindrome(\"not a palindrome\") === false, '\"not a palindrome\" should return false.');", - "assert(palindrome(\"A man, a plan, a canal. Panama\") === true, '\"A man, a plan, a canal. Panama\" should return true.');", - "assert(palindrome(\"never odd or even\") === true, '\"never odd or even\" should return true.');", - "assert(palindrome(\"nope\") === false, '\"nope\" should return false.');", - "assert(palindrome(\"almostomla\") === false, '\"almostomla\" should return false.');", - "assert(palindrome(\"My age is 0, 0 si ega ym.\") === true, '\"My age is 0, 0 si ega ym.\" should return true.');", - "assert(palindrome(\"1 eye for of 1 eye.\") === false, '\"1 eye for of 1 eye.\" should return false.');", - "assert(palindrome(\"0_0 (: /-\\ :) 0-0\") === true, '\"0_0 (: /-\\\\ :) 0-0\" should return true.');" + "assert(typeof(palindrome(\"eye\")) === \"boolean\", 'message: palindrome() should return a boolean.');", + "assert(palindrome(\"eye\") === true, 'message: palindrome(\"eye\") should return true.');", + "assert(palindrome(\"race car\") === true, 'message: palindrome(\"race car\") should return true.');", + "assert(palindrome(\"not a palindrome\") === false, 'message: palindrome(\"not a palindrome\") should return false.');", + "assert(palindrome(\"A man, a plan, a canal. Panama\") === true, 'message: palindrome(\"A man, a plan, a canal. Panama\") should return true.');", + "assert(palindrome(\"never odd or even\") === true, 'message: palindrome(\"never odd or even\") should return true.');", + "assert(palindrome(\"nope\") === false, 'message: palindrome(\"nope\") should return false.');", + "assert(palindrome(\"almostomla\") === false, 'message: palindrome(\"almostomla\") should return false.');", + "assert(palindrome(\"My age is 0, 0 si ega ym.\") === true, 'message: palindrome(\"My age is 0, 0 si ega ym.\") should return true.');", + "assert(palindrome(\"1 eye for of 1 eye.\") === false, 'message: palindrome(\"1 eye for of 1 eye.\") should return false.');", + "assert(palindrome(\"0_0 (: /-\\ :) 0-0\") === true, 'message: palindrome(\"0_0 (: /-\\\\ :) 0-0\") should return true.');" ], "challengeSeed": [ "function palindrome(str) {", @@ -192,12 +192,12 @@ "findLongestWord(\"The quick brown fox jumped over the lazy dog\");" ], "tests": [ - "assert(typeof(findLongestWord(\"The quick brown fox jumped over the lazy dog\")) === \"number\", 'findLongestWord() should return a number.');", - "assert(findLongestWord(\"The quick brown fox jumped over the lazy dog\") === 6, '\"The quick brown fox jumped over the lazy dog\" should return 6.');", - "assert(findLongestWord(\"May the force be with you\") === 5, '\"May the force be with you\" should return 5.');", - "assert(findLongestWord(\"Google do a barrel roll\") === 6, '\"Google do a barrel roll\" should return 6.');", - "assert(findLongestWord(\"What is the average airspeed velocity of an unladen swallow\") === 8, '\"What is the average airspeed velocity of an unladen swallow\" should return 8.');", - "assert(findLongestWord(\"What if we try a super-long word such as otorhinolaryngology\") === 19, '\"What if we try a super-long word such as otorhinolaryngology\" should return 19.');" + "assert(typeof(findLongestWord(\"The quick brown fox jumped over the lazy dog\")) === \"number\", 'message: findLongestWord() should return a number.');", + "assert(findLongestWord(\"The quick brown fox jumped over the lazy dog\") === 6, 'message: findLongestWord(\"The quick brown fox jumped over the lazy dog\") should return 6.');", + "assert(findLongestWord(\"May the force be with you\") === 5, 'message: findLongestWord(\"May the force be with you\") should return 5.');", + "assert(findLongestWord(\"Google do a barrel roll\") === 6, 'message: findLongestWord(\"Google do a barrel roll\") should return 6.');", + "assert(findLongestWord(\"What is the average airspeed velocity of an unladen swallow\") === 8, 'message: findLongestWord(\"What is the average airspeed velocity of an unladen swallow\") should return 8.');", + "assert(findLongestWord(\"What if we try a super-long word such as otorhinolaryngology\") === 19, 'message: findLongestWord(\"What if we try a super-long word such as otorhinolaryngology\") should return 19.');" ], "MDNlinks": [ "String.split()", @@ -233,10 +233,10 @@ "titleCase(\"I'm a little tea pot\", \"\");" ], "tests": [ - "assert(typeof(titleCase(\"I'm a little tea pot\")) === \"string\", 'titleCase() should return a string.');", - "assert(titleCase(\"I'm a little tea pot\") === \"I'm A Little Tea Pot\", '\"I'm a little tea pot\" should return \"I'm A Little Tea Pot\".');", - "assert(titleCase(\"sHoRt AnD sToUt\") === \"Short And Stout\", '\"sHoRt AnD sToUt\" should return \"Short And Stout\".');", - "assert(titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") === \"Here Is My Handle Here Is My Spout\", '\"HERE IS MY HANDLE HERE IS MY SPOUT\" should return \"Here Is My Handle Here Is My Spout\"');" + "assert(typeof(titleCase(\"I'm a little tea pot\")) === \"string\", 'message: titleCase() should return a string.');", + "assert(titleCase(\"I'm a little tea pot\") === \"I'm A Little Tea Pot\", 'message: titleCase(\"I'm a little tea pot\") should return \"I'm A Little Tea Pot\".');", + "assert(titleCase(\"sHoRt AnD sToUt\") === \"Short And Stout\", 'message: titleCase(\"sHoRt AnD sToUt\") should return \"Short And Stout\".');", + "assert(titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") === \"Here Is My Handle Here Is My Spout\", 'message: titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") should return \"Here Is My Handle Here Is My Spout\".');" ], "MDNlinks": [ "String.charAt()" @@ -270,12 +270,12 @@ " return arr;", "}", "", - "largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]], \"\");" + "largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);" ], "tests": [ - "assert(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]).constructor === Array, 'largestOfFour() should return an array.');", - "assert.deepEqual(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]), [27,5,39,1001], '[[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]] should return [27,5,39,1001].');", - "assert.deepEqual(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]), [9,35,97,1000000], '[[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]] should return [9, 35, 97, 1000000].');" + "assert(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]).constructor === Array, 'message: largestOfFour() should return an array.');", + "assert.deepEqual(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]), [27,5,39,1001], 'message: largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) should return [27,5,39,1001].');", + "assert.deepEqual(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]), [9,35,97,1000000], 'message: largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]) should return [9, 35, 97, 1000000].');" ], "MDNlinks": [ "Comparison Operators" @@ -311,11 +311,11 @@ "end(\"Bastian\", \"n\", \"\");" ], "tests": [ - "assert(end(\"Bastian\", \"n\") === true, '\"Bastian\", \"n\" should return true.');", - "assert(end(\"Connor\", \"n\") === false, '\"Connor\", \"n\" should return false.');", - "assert(end(\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\") === false, '\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\") should return false.');", - "assert(end(\"He has to give me a new name\", \"name\") === true, '\"He has to give me a new name\", \"name\" should return true.');", - "assert(end(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") === false, '\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\" should return false.');" + "assert(end(\"Bastian\", \"n\") === true, 'message: end(\"Bastian\", \"n\") should return true.');", + "assert(end(\"Connor\", \"n\") === false, 'message: end(\"Connor\", \"n\") should return false.');", + "assert(end(\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\") === false, 'message: end(\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\") should return false.');", + "assert(end(\"He has to give me a new name\", \"name\") === true, 'message: end(\"He has to give me a new name\", \"name\") should return true.');", + "assert(end(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") === false, 'message: end(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") should return false.');" ], "MDNlinks": [ "String.substr()" @@ -350,9 +350,9 @@ "repeat(\"abc\", 3, \"\");" ], "tests": [ - "assert(repeat(\"*\", 3) === \"***\", '\"*\", 3 should return \"***\".');", - "assert(repeat(\"abc\", 3) === \"abcabcabc\", '\"abc\", 3 should return \"abcabcabc\".');", - "assert(repeat(\"abc\", -2) === \"\", '\"abc\", -2 should return \"\".');" + "assert(repeat(\"*\", 3) === \"***\", 'message: repeat(\"*\", 3) should return \"***\".');", + "assert(repeat(\"abc\", 3) === \"abcabcabc\", 'message: repeat(\"abc\", 3) should return \"abcabcabc\".');", + "assert(repeat(\"abc\", -2) === \"\", 'message: repeat(\"abc\", -2) should return \"\".');" ], "MDNlinks": [ "Global String Object" @@ -388,10 +388,10 @@ "truncate(\"A-tisket a-tasket A green and yellow basket\", 11, \"\");" ], "tests": [ - "assert(truncate(\"A-tisket a-tasket A green and yellow basket\", 11) === \"A-tisket...\", '\"A-tisket a-tasket A green and yellow basket\", 1 should return \"A-tisket...\".');", - "assert(truncate(\"Peter Piper picked a peck of pickled peppers\", 14) === \"Peter Piper...\", '\"Peter Piper picked a peck of pickled peppers\", 14 should return \"Peter Piper...\".');", - "assert(truncate(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) === \"A-tisket a-tasket A green and yellow basket\", '\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) should return \"A-tisket a-tasket A green and yellow basket\".');", - "assert(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length + 2) === 'A-tisket a-tasket A green and yellow basket', '\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length + 2 should return \"A-tisket a-tasket A green and yellow basket\".');" + "assert(truncate(\"A-tisket a-tasket A green and yellow basket\", 11) === \"A-tisket...\", 'message: truncate(\"A-tisket a-tasket A green and yellow basket\", 1) should return \"A-tisket...\".');", + "assert(truncate(\"Peter Piper picked a peck of pickled peppers\", 14) === \"Peter Piper...\", 'message: truncate(\"Peter Piper picked a peck of pickled peppers\", 14) should return \"Peter Piper...\".');", + "assert(truncate(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) === \"A-tisket a-tasket A green and yellow basket\", 'message: truncate(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) should return \"A-tisket a-tasket A green and yellow basket\".');", + "assert(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length + 2) === 'A-tisket a-tasket A green and yellow basket', 'message: truncate(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length + 2) should return \"A-tisket a-tasket A green and yellow basket\".');" ], "MDNlinks": [ "String.slice()" @@ -426,10 +426,10 @@ "chunk([\"a\", \"b\", \"c\", \"d\"], 2, \"\");" ], "tests": [ - "assert.deepEqual(chunk([\"a\", \"b\", \"c\", \"d\"], 2), [[\"a\", \"b\"], [\"c\", \"d\"]], '[\"a\", \"b\", \"c\", \"d\"], 2 should return [[\"a\", \"b\"], [\"c\", \"d\"]].');", - "assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 3), [[0, 1, 2], [3, 4, 5]], '[0, 1, 2, 3, 4, 5] should return [[0, 1, 2], [3, 4, 5]].');", - "assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 2), [[0, 1], [2, 3], [4, 5]], '[0, 1, 2, 3, 4, 5], 2 should return [[0, 1], [2, 3], [4, 5]].');", - "assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 4), [[0, 1, 2, 3], [4, 5]], '[0, 1, 2, 3, 4, 5], 4 should return [[0, 1, 2, 3], [4, 5]].');" + "assert.deepEqual(chunk([\"a\", \"b\", \"c\", \"d\"], 2), [[\"a\", \"b\"], [\"c\", \"d\"]], 'message: chunk([\"a\", \"b\", \"c\", \"d\"], 2) should return [[\"a\", \"b\"], [\"c\", \"d\"]].');", + "assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 3), [[0, 1, 2], [3, 4, 5]], 'message: chunk([0, 1, 2, 3, 4, 5], 3) should return [[0, 1, 2], [3, 4, 5]].');", + "assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 2), [[0, 1], [2, 3], [4, 5]], 'message: chunk([0, 1, 2, 3, 4, 5], 2) should return [[0, 1], [2, 3], [4, 5]].');", + "assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 4), [[0, 1, 2, 3], [4, 5]], 'message: chunk([0, 1, 2, 3, 4, 5], 4) should return [[0, 1, 2, 3], [4, 5]].');" ], "MDNlinks": [ "Array.push()" @@ -464,9 +464,9 @@ "slasher([1, 2, 3], 2, \"\");" ], "tests": [ - "assert.deepEqual(slasher([1, 2, 3], 2), [3], 'slasher([1, 2, 3], 2) should return [3].');", - "assert.deepEqual(slasher([1, 2, 3], 0), [1, 2, 3], 'slasher([1, 2, 3], 0) should return [1, 2, 3].');", - "assert.deepEqual(slasher([1, 2, 3], 9), [], 'slasher([1, 2, 3], 9) should return [].');" + "assert.deepEqual(slasher([1, 2, 3], 2), [3], 'message: slasher([1, 2, 3], 2, [3]) should return [3].');", + "assert.deepEqual(slasher([1, 2, 3], 0), [1, 2, 3], 'message: slasher([1, 2, 3], 0) should return [1, 2, 3].');", + "assert.deepEqual(slasher([1, 2, 3], 9), [], 'message: slasher([1, 2, 3], 9) should return [].');" ], "MDNlinks": [ "Array.slice()", @@ -504,14 +504,14 @@ "mutation([\"hello\", \"hey\"], \"\");" ], "tests": [ - "assert(mutation([\"hello\", \"hey\"]) === false, '[\"hello\", \"hey\"] should return false.');", - "assert(mutation([\"hello\", \"Hello\"]) === true, '[\"hello\", \"Hello\"] should return true.');", - "assert(mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) === true, '[\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"] should return true.');", - "assert(mutation([\"Mary\", \"Army\"]) === true, '[\"Mary\", \"Army\"] should return true.');", - "assert(mutation([\"Mary\", \"Aarmy\"]) === true, '[\"Mary\", \"Aarmy\"] should return true.');", - "assert(mutation([\"Alien\", \"line\"]) === true, '[\"Alien\", \"line\"] should return true.');", - "assert(mutation([\"floor\", \"for\"]) === true, '[\"floor\", \"for\"] should return true.');", - "assert(mutation([\"hello\", \"neo\"]) === false, '[\"hello\", \"neo\"] should return false.');" + "assert(mutation([\"hello\", \"hey\"]) === false, 'message: mutation([\"hello\", \"hey\"]) should return false.');", + "assert(mutation([\"hello\", \"Hello\"]) === true, 'message: mutation([\"hello\", \"Hello\"]) should return true.');", + "assert(mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) === true, 'message: mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) should return true.');", + "assert(mutation([\"Mary\", \"Army\"]) === true, 'message: mutation([\"Mary\", \"Army\"]) should return true.');", + "assert(mutation([\"Mary\", \"Aarmy\"]) === true, 'message: mutation([\"Mary\", \"Aarmy\"]) should return true.');", + "assert(mutation([\"Alien\", \"line\"]) === true, 'message: mutation([\"Alien\", \"line\"]) should return true.');", + "assert(mutation([\"floor\", \"for\"]) === true, 'message: mutation([\"floor\", \"for\"]) should return true.');", + "assert(mutation([\"hello\", \"neo\"]) === false, 'message: mutation([\"hello\", \"neo\"]) should return false.');" ], "MDNlinks": [ "Array.indexOf()" @@ -535,7 +535,7 @@ "difficulty": "1.50", "description": [ "Remove all falsy values from an array.", - "Falsy values in javascript are false, null, 0, \"\", undefined, and NaN.", + "Falsy values in javascript are false, null, 0, \"\", undefined, and NaN.", "Remember to use Read-Search-Ask if you get stuck. Write your own code." ], "challengeSeed": [ @@ -547,9 +547,9 @@ "bouncer([7, \"ate\", \"\", false, 9], \"\");" ], "tests": [ - "assert.deepEqual(bouncer([7, \"ate\", \"\", false, 9]), [7, \"ate\", 9], '[7, \"ate\", \"\", false, 9] should return [7, \"ate\", 9].');", - "assert.deepEqual(bouncer([\"a\", \"b\", \"c\"]), [\"a\", \"b\", \"c\"], '[\"a\", \"b\", \"c\"] should return [\"a\", \"b\", \"c\"].');", - "assert.deepEqual(bouncer([false, null, 0, NaN, undefined, '']), [], '[false, null, 0] should return [].');" + "assert.deepEqual(bouncer([7, \"ate\", \"\", false, 9]), [7, \"ate\", 9], 'message: bouncer([7, \"ate\", \"\", false, 9]) should return [7, \"ate\", 9].');", + "assert.deepEqual(bouncer([\"a\", \"b\", \"c\"]), [\"a\", \"b\", \"c\"], 'message: bouncer([\"a\", \"b\", \"c\"]) should return [\"a\", \"b\", \"c\"].');", + "assert.deepEqual(bouncer([false, null, 0, NaN, undefined, \"\"]), [], 'message: bouncer([false, null, 0, NaN, undefined, \"\"]) should return [].');" ], "MDNlinks": [ "Boolean Objects", @@ -585,11 +585,11 @@ "destroyer([1, 2, 3, 1, 2, 3], 2, 3, \"\");" ], "tests": [ - "assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1], '[1, 2, 3, 1, 2, 3], 2, 3 should return [1, 1].');", - "assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1], '[1, 2, 3, 5, 1, 2, 3], 2, 3 should return [1, 5, 1].');", - "assert.deepEqual(destroyer([3, 5, 1, 2, 2], 2, 3, 5), [1], '[3, 5, 1, 2, 2], 2, 3, 5 should return [1].');", - "assert.deepEqual(destroyer([2, 3, 2, 3], 2, 3), [], '[2, 3, 2, 3], 2, 3 should return [].');", - "assert.deepEqual(destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53), [\"hamburger\"], '[\"tree\", \"hamburger\", 53], \"tree\", 53) should return [\"hamburger\"].');" + "assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1], 'message: destroyer([1, 2, 3, 1, 2, 3], 2, 3) should return [1, 1].');", + "assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1], 'message: destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) should return [1, 5, 1].');", + "assert.deepEqual(destroyer([3, 5, 1, 2, 2], 2, 3, 5), [1], 'message: destroyer([3, 5, 1, 2, 2], 2, 3, 5) should return [1].');", + "assert.deepEqual(destroyer([2, 3, 2, 3], 2, 3), [], 'message: destroyer([2, 3, 2, 3], 2, 3) should return [].');", + "assert.deepEqual(destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53), [\"hamburger\"], 'message: destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53) should return [\"hamburger\"].');" ], "MDNlinks": [ "Arguments object", @@ -629,12 +629,12 @@ "Array.sort()" ], "tests": [ - "assert(where([10, 20, 30, 40, 50], 35) === 3, '[10, 20, 30, 40, 50], 35 should return 3.');", - "assert(where([10, 20, 30, 40, 50], 30) === 2, '[10, 20, 30, 40, 50], 30) should return 2.');", - "assert(where([40, 60], 50) === 1, '[40, 60,], 50 should return 1.');", - "assert(where([5, 3, 20, 3], 3) === 0, '[5, 3, 20, 3], 3 should return 0.');", - "assert(where([2, 20, 10], 1) === 0, '[2, 20, 10], 1 should return 0.');", - "assert(where([2, 5, 10], 15) === 3, '[2, 5, 10], 15 should return 3.');" + "assert(where([10, 20, 30, 40, 50], 35) === 3, 'message: where([10, 20, 30, 40, 50], 35) should return 3.');", + "assert(where([10, 20, 30, 40, 50], 30) === 2, 'message: where([10, 20, 30, 40, 50], 30) should return 2.');", + "assert(where([40, 60], 50) === 1, 'message: where([40, 60,], 50) should return 1.');", + "assert(where([5, 3, 20, 3], 3) === 0, 'message: where([5, 3, 20, 3], 3) should return 0.');", + "assert(where([2, 20, 10], 1) === 0, 'message: where([2, 20, 10], 1) should return 0.');", + "assert(where([2, 5, 10], 15) === 3, 'message: where([2, 5, 10], 15) should return 3.');" ], "type": "bonfire", "challengeType": 5, diff --git a/challenges/basic-javascript.json b/challenges/basic-javascript.json index 80ff4839bf..1c7ecb2b7e 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\"]];", @@ -678,7 +678,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;", @@ -724,10 +724,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 = {", @@ -766,8 +766,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 = {", @@ -817,8 +817,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 = [];", @@ -856,8 +856,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 = [];", @@ -884,9 +884,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() {", @@ -917,10 +917,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(){", @@ -949,10 +949,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;", @@ -988,10 +988,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;", @@ -1026,8 +1026,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() {", @@ -1057,8 +1057,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() {", @@ -1087,8 +1087,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(){", @@ -1115,8 +1115,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(){", @@ -1146,10 +1146,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", @@ -1616,7 +1616,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/intermediate-bonfires.json b/challenges/intermediate-bonfires.json index f9080c7214..684afd44e8 100644 --- a/challenges/intermediate-bonfires.json +++ b/challenges/intermediate-bonfires.json @@ -19,11 +19,11 @@ "sumAll([1, 4]);" ], "tests": [ - "assert(typeof(sumAll([1, 4])) === \"number\", 'The result should be a number');", - "assert.deepEqual(sumAll([1, 4]), 10, 'sumAll([1, 4]) should return 10');", - "assert.deepEqual(sumAll([4, 1]), 10, 'sumAll([4, 1]) should return 10');", - "assert.deepEqual(sumAll([5, 10]), 45, 'sumAll([5, 10]) should return 45');", - "assert.deepEqual(sumAll([10, 5]), 45, 'sumAll([10, 5]) should return 45');" + "assert(typeof(sumAll([1, 4])) === \"number\", 'message: sumAll() should return a number.');", + "assert.deepEqual(sumAll([1, 4]), 10, 'message: sumAll([1, 4]) should return 10.');", + "assert.deepEqual(sumAll([4, 1]), 10, 'message: sumAll([4, 1]) should return 10.');", + "assert.deepEqual(sumAll([5, 10]), 45, 'message: sumAll([5, 10]) should return 45.');", + "assert.deepEqual(sumAll([10, 5]), 45, 'message: sumAll([10, 5]) should return 45.');" ], "MDNlinks": [ "Math.max()", @@ -61,13 +61,13 @@ "diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);" ], "tests": [ - "assert(typeof(diff([1, 2, 3, 5], [1, 2, 3, 4, 5])) === \"object\", 'The result should be an array.');", - "assert.deepEqual(diff(['diorite', 'andesite', 'grass', 'dirt', 'pink wool', 'dead shrub'], ['diorite', 'andesite', 'grass', 'dirt', 'dead shrub']), ['pink wool'], 'arrays with only one difference');", - "assert.includeMembers(diff(['andesite', 'grass', 'dirt', 'pink wool', 'dead shrub'], ['diorite', 'andesite', 'grass', 'dirt', 'dead shrub']), ['diorite', 'pink wool'], 'arrays with more than one difference');", - "assert.deepEqual(diff(['andesite', 'grass', 'dirt', 'dead shrub'], ['andesite', 'grass', 'dirt', 'dead shrub']), [], 'arrays with no difference');", - "assert.deepEqual(diff([1, 2, 3, 5], [1, 2, 3, 4, 5]), [4], 'arrays with numbers');", - "assert.includeMembers(diff([1, 'calf', 3, 'piglet'], [1, 'calf', 3, 4]), ['piglet', 4], 'arrays with numbers and strings');", - "assert.deepEqual(diff([], ['snuffleupagus', 'cookie monster', 'elmo']), ['snuffleupagus', 'cookie monster', 'elmo'], 'empty array');" + "assert(typeof(diff([1, 2, 3, 5], [1, 2, 3, 4, 5])) === \"object\", 'message: diff() should return an array.');", + "assert.deepEqual(diff([\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [\"pink wool\"], 'message: [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"] should return [\"pink wool\"].');", + "assert.includeMembers(diff([\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [\"diorite\", \"pink wool\"], 'message: [\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"] should return [\"diorite\", \"pink wool\"].');", + "assert.deepEqual(diff([\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [], 'message: [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"] should return [].');", + "assert.deepEqual(diff([1, 2, 3, 5], [1, 2, 3, 4, 5]), [4], 'message: [1, 2, 3, 5], [1, 2, 3, 4, 5] should return [4].');", + "assert.includeMembers(diff([1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]), [\"piglet\", 4], 'message: [1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4] should return [\"piglet\", 4].');", + "assert.deepEqual(diff([], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]), [\"snuffleupagus\", \"cookie monster\", \"elmo\"], 'message: [], [\"snuffleupagus\", \"cookie monster\", \"elmo\"] should return [\"snuffleupagus\", \"cookie monster\", \"elmo\"].');" ], "MDNlinks": [ "Comparison Operators", @@ -93,11 +93,11 @@ "id": "a7f4d8f2483413a6ce226cac", "title": "Roman Numeral Converter", "tests": [ - "assert.deepEqual(convert(12), \"XII\", 'convert(12) should return \"XII\"');", - "assert.deepEqual(convert(5), \"V\", 'convert(5) should return \"V\"');", - "assert.deepEqual(convert(9), \"IX\", 'convert(9) should return \"IX\"');", - "assert.deepEqual(convert(29), \"XXIX\", 'convert(29) should return \"XXIX\"');", - "assert.deepEqual(convert(16), \"XVI\", 'convert(16) should return \"XVI\"');" + "assert.deepEqual(convert(12), \"XII\", 'message: convert(12) should return \"XII\".');", + "assert.deepEqual(convert(5), \"V\", 'message: convert(5) should return \"V\".');", + "assert.deepEqual(convert(9), \"IX\", 'message: convert(9) should return \"IX\".');", + "assert.deepEqual(convert(29), \"XXIX\", 'message: convert(29) should return \"XXIX\".');", + "assert.deepEqual(convert(16), \"XVI\", 'message: convert(16) should return \"XVI\".');" ], "difficulty": "2.02", "description": [ @@ -137,7 +137,7 @@ "difficulty": "2.03", "description": [ "Make a function that looks through an array of objects (first argument) and returns an array of all objects that have matching property and value pairs (second argument). Each property and value pair of the source object has to be present in the object from the collection if it is to be included in the returned array.", - "For example, if the first argument is [{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], and the second argument is { last: 'Capulet' }, then you must return the third object from the array (the first argument), because it contains the property and it's value, that was passed on as the second argument.", + "For example, if the first argument is [{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], and the second argument is { last: \"Capulet\" }, then you must return the third object from the array (the first argument), because it contains the property and it's value, that was passed on as the second argument.", "Remember to use Read-Search-Ask if you get stuck. Write your own code." ], "challengeSeed": [ @@ -147,13 +147,12 @@ " return arr;", "}", "", - "where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' });" + "where([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" });" ], "tests": [ - "assert.deepEqual(where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' }), [{ first: 'Tybalt', last: 'Capulet' }], 'should return an array of objects');", - "assert.deepEqual(where([{ 'a': 1 }, { 'a': 1 }, { 'a': 1, 'b': 2 }], { 'a': 1 }), [{ 'a': 1 }, { 'a': 1 }, { 'a': 1, 'b': 2 }], 'should return with multiples');", - "assert.deepEqual(where([{ 'a': 1, 'b': 2 }, { 'a': 1 }, { 'a': 1, 'b': 2, 'c': 2 }], { 'a': 1, 'b': 2 }), [{ 'a': 1, 'b': 2 }, { 'a': 1, 'b': 2, 'c': 2 }], 'should return two objects in array');", - "assert.deepEqual(where([{ 'a': 5 }, { 'b': 10 }, { 'a': 5, 'b': 10 }], { 'a': 5, 'b': 10 }), [{ 'a': 5, 'b': 10 }], 'should return a single object in array');" + "assert.deepEqual(where([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" }), [{ first: \"Tybalt\", last: \"Capulet\" }], 'message: where() should return an array of objects.');", + "assert.deepEqual(where([{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }], { \"a\": 1 }), [{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }], 'message: where([{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }], { \"a\": 1 }) should return [{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }].');", + "assert.deepEqual(where([{ \"a\": 1, \"b\": 2 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], { \"a\": 1, \"b\": 2 }), [{ \"a\": 1, \"b\": 2 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], 'message: where([{ \"a\": 1, \"b\": 2 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], { \"a\": 1, \"b\": 2 }) should return [{ \"a\": 1, \"b\": 2 }, { \"a\": 1, \"b\": 2, \"c\": 2 }].');" ], "MDNlinks": [ "Global Object", @@ -177,11 +176,11 @@ "id": "a0b5010f579e69b815e7c5d6", "title": "Search and Replace", "tests": [ - "assert.deepEqual(replace(\"Let us go to the store\", \"store\", \"mall\"), \"Let us go to the mall\", 'replace(\"Let us go to the store\", \"store\", \"mall\") should return \"Let us go to the mall\"');", - "assert.deepEqual(replace(\"He is Sleeping on the couch\", \"Sleeping\", \"sitting\"), \"He is Sitting on the couch\", 'replace(\"He is Sleeping on the couch\", \"Sleeping\", \"sitting\") should return \"He is Sitting on the couch\"');", - "assert.deepEqual(replace(\"This has a spellngi error\", \"spellngi\", \"spelling\"), \"This has a spelling error\", 'replace(\"This has a spellngi error\", \"spellingi\", \"spelling\") should return \"This has a spelling error\"');", - "assert.deepEqual(replace(\"His name is Tom\", \"Tom\", \"john\"), \"His name is John\", 'replace(\"His name is Tom\", \"Tom\", \"john\") should return \"His name is John\"');", - "assert.deepEqual(replace(\"Let us get back to more Coding\", \"Coding\", \"bonfires\"), \"Let us get back to more Bonfires\", 'replace(\"Let us get back to more Coding\", \"Coding\", \"bonfires\") should return \"Let us get back to more Bonfires\"');" + "assert.deepEqual(myReplace(\"Let us go to the store\", \"store\", \"mall\"), \"Let us go to the mall\", 'message: myReplace(\"Let us go to the store\", \"store\", \"mall\") should return \"Let us go to the mall\".');", + "assert.deepEqual(myReplace(\"He is Sleeping on the couch\", \"Sleeping\", \"sitting\"), \"He is Sitting on the couch\", 'message: myReplace(\"He is Sleeping on the couch\", \"Sleeping\", \"sitting\") should return \"He is Sitting on the couch\".');", + "assert.deepEqual(myReplace(\"This has a spellngi error\", \"spellngi\", \"spelling\"), \"This has a spelling error\", 'message: myReplace(\"This has a spellngi error\", \"spellingi\", \"spelling\") should return \"This has a spelling error\".');", + "assert.deepEqual(myReplace(\"His name is Tom\", \"Tom\", \"john\"), \"His name is John\", 'message: myReplace(\"His name is Tom\", \"Tom\", \"john\") should return \"His name is John\".');", + "assert.deepEqual(myReplace(\"Let us get back to more Coding\", \"Coding\", \"bonfires\"), \"Let us get back to more Bonfires\", 'message: myReplace(\"Let us get back to more Coding\", \"Coding\", \"bonfires\") should return \"Let us get back to more Bonfires\".');" ], "difficulty": "2.035", "description": [ @@ -189,7 +188,7 @@ "First argument is the sentence to perform the search and replace on.", "Second argument is the word that you will be replacing (before).", "Third argument is what you will be replacing the second argument with (after).", - "NOTE: Preserve the case of the original word when you are replacing it. For example if you mean to replace the word 'Book' with the word 'dog', it should be replaced as 'Dog'", + "NOTE: Preserve the case of the original word when you are replacing it. For example if you mean to replace the word \"Book\" with the word \"dog\", it should be replaced as \"Dog\"", "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code." ], "challengeSeed": [ @@ -221,11 +220,11 @@ "id": "aa7697ea2477d1316795783b", "title": "Pig Latin", "tests": [ - "assert.deepEqual(translate(\"california\"), \"aliforniacay\", 'translate(\"california\") should return \"aliforniacay\"');", - "assert.deepEqual(translate(\"paragraphs\"), \"aragraphspay\", 'translate(\"paragraphs\") should return \"aragraphspay\"');", - "assert.deepEqual(translate(\"glove\"), \"oveglay\", 'translate(\"glove\") should return \"oveglay\"');", - "assert.deepEqual(translate(\"algorithm\"), \"algorithmway\", 'translate(\"algorithm\") should return \"algorithmway\"');", - "assert.deepEqual(translate(\"eight\"), \"eightway\", 'translate(\"eight\") should return \"eightway\"');" + "assert.deepEqual(translate(\"california\"), \"aliforniacay\", 'message: translate(\"california\") should return \"aliforniacay\".');", + "assert.deepEqual(translate(\"paragraphs\"), \"aragraphspay\", 'message: translate(\"paragraphs\") should return \"aragraphspay\".');", + "assert.deepEqual(translate(\"glove\"), \"oveglay\", 'message: translate(\"glove\") should return \"oveglay\".');", + "assert.deepEqual(translate(\"algorithm\"), \"algorithmway\", 'message: translate(\"algorithm\") should return \"algorithmway\".');", + "assert.deepEqual(translate(\"eight\"), \"eightway\", 'message: translate(\"eight\") should return \"eightway\".');" ], "difficulty": "2.04", "description": [ @@ -265,16 +264,16 @@ "id": "afd15382cdfb22c9efe8b7de", "title": "DNA Pairing", "tests": [ - "assert.deepEqual(pair(\"ATCGA\"),[['A','T'],['T','A'],['C','G'],['G','C'],['A','T']], 'should return the dna pair');", - "assert.deepEqual(pair(\"TTGAG\"),[['T','A'],['T','A'],['G','C'],['A','T'],['G','C']], 'should return the dna pair');", - "assert.deepEqual(pair(\"CTCTA\"),[['C','G'],['T','A'],['C','G'],['T','A'],['A','T']], 'should return the dna pair');" + "assert.deepEqual(pair(\"ATCGA\"),[[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]], 'message: pair(\"ATCGA\") should return [[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]].');", + "assert.deepEqual(pair(\"TTGAG\"),[[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]], 'message: pair(\"TTGAG\") should return [[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]].');", + "assert.deepEqual(pair(\"CTCTA\"),[[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]], 'message: pair(\"CTCTA\") should return [[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]].');" ], "difficulty": "2.05", "description": [ "The DNA strand is missing the pairing element. Take each character, get its pair, and return the results as a 2d array.", "Base pairs are a pair of AT and CG. Match the missing element to the provided character.", "Return the provided character as the first element in each array.", - "For example, for the input GCG, return [['G', 'C'], ['C','G'],['G', 'C']]", + "For example, for the input GCG, return [[\"G\", \"C\"], [\"C\",\"G\"],[\"G\", \"C\"]]", "The character and its pair are paired up in an array, and all the arrays are grouped into one encapsulating array.", "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code." ], @@ -316,13 +315,13 @@ " return str;", "}", "", - "fearNotLetter('abce');" + "fearNotLetter(\"abce\");" ], "tests": [ - "assert.deepEqual(fearNotLetter(\"abce\"), \"d\", 'fearNotLetter(\"abce\") should return d');", - "assert.deepEqual(fearNotLetter(\"abcdefghjklmno\"), \"i\", 'fearNotLetter(\"abcdefghjklmno\") should return i');", - "assert.isUndefined(fearNotLetter(\"bcd\"), 'fearNotLetter(\"bcd\") should return undefined');", - "assert.isUndefined(fearNotLetter(\"yz\"), 'fearNotLetter(\"yz\") should return undefined');" + "assert.deepEqual(fearNotLetter(\"abce\"), \"d\", 'message: fearNotLetter(\"abce\") should return \"d\".');", + "assert.deepEqual(fearNotLetter(\"abcdefghjklmno\"), \"i\", 'message: fearNotLetter(\"abcdefghjklmno\") should return \"i\".');", + "assert.isUndefined(fearNotLetter(\"bcd\"), 'message: fearNotLetter(\"bcd\") should return undefined.');", + "assert.isUndefined(fearNotLetter(\"yz\"), 'message: fearNotLetter(\"yz\") should return undefined.');" ], "MDNlinks": [ "String.charCodeAt()", @@ -359,14 +358,14 @@ "boo(null);" ], "tests": [ - "assert.strictEqual(boo(true), true);", - "assert.strictEqual(boo(false), true);", - "assert.strictEqual(boo([1, 2, 3]), false);", - "assert.strictEqual(boo([].slice), false);", - "assert.strictEqual(boo({ 'a': 1 }), false);", - "assert.strictEqual(boo(1), false);", - "assert.strictEqual(boo(NaN), false);", - "assert.strictEqual(boo('a'), false);" + "assert.strictEqual(boo(true), true, 'message: boo(true) should return true.');", + "assert.strictEqual(boo(false), true, 'message: boo(false) should return true.');", + "assert.strictEqual(boo([1, 2, 3]), false, 'message: boo([1, 2, 3]) should return false.');", + "assert.strictEqual(boo([].slice), false, 'message: boo([].slice) should return false.');", + "assert.strictEqual(boo({ \"a\": 1 }), false, 'message: boo({ \"a\": 1 }) should return false.');", + "assert.strictEqual(boo(1), false, 'message: boo(1) should return false.');", + "assert.strictEqual(boo(NaN), false, 'message: boo(NaN) should return true.');", + "assert.strictEqual(boo(\"a\"), false, 'message: boo(\"a\") should return false.');" ], "MDNlinks": [ "Boolean Objects" @@ -403,10 +402,10 @@ "unite([1, 3, 2], [5, 2, 1, 4], [2, 1]);" ], "tests": [ - "assert.deepEqual(unite([1, 3, 2], [5, 2, 1, 4], [2, 1]), [1, 3, 2, 5, 4], 'should return the union of the given arrays');", - "assert.deepEqual(unite([1, 3, 2], [1, [5]], [2, [4]]), [1, 3, 2, [5], [4]], 'should not flatten nested arrays');", - "assert.deepEqual(unite([1, 2, 3], [5, 2, 1]), [1, 2, 3, 5], 'should correctly handle exactly two arguments');", - "assert.deepEqual(unite([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]), [ 1, 2, 3, 5, 4, 6, 7, 8 ], 'should correctly handle higher numbers of arguments');" + "assert.deepEqual(unite([1, 3, 2], [5, 2, 1, 4], [2, 1]), [1, 3, 2, 5, 4], 'message: unite([1, 3, 2], [5, 2, 1, 4], [2, 1]) should return [1, 3, 2, 5, 4].');", + "assert.deepEqual(unite([1, 3, 2], [1, [5]], [2, [4]]), [1, 3, 2, [5], [4]], 'message: unite([1, 3, 2], [1, [5]], [2, [4]]) should return [1, 3, 2, [5], [4]].');", + "assert.deepEqual(unite([1, 2, 3], [5, 2, 1]), [1, 2, 3, 5], 'message: unite([1, 2, 3], [5, 2, 1]) should return [1, 2, 3, 5].');", + "assert.deepEqual(unite([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]), [1, 2, 3, 5, 4, 6, 7, 8], 'message: unite([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]) should return [1, 2, 3, 5, 4, 6, 7, 8].');" ], "MDNlinks": [ "Arguments object", @@ -439,16 +438,16 @@ " return str;", "}", "", - "convert('Dolce & Gabbana');" + "convert(\"Dolce & Gabbana\");" ], "tests": [ - "assert.match(convert('Dolce & Gabbana'), /Dolce &(amp|AMP|#x00026|#38); Gabbana/, 'should escape characters');", - "assert.match(convert('Hamburgers < Pizza < Tacos'), /Hamburgers &(lt|LT|#x0003C|#60); Pizza &(lt|LT|#x0003C|#60); Tacos/, 'should escape characters');", - "assert.match(convert('Sixty > twelve'), /Sixty &(gt|GT|#x0003E|#62); twelve/, 'should escape characters');", - "assert.match(convert('Stuff in \"quotation marks\"'), /Stuff in &(quot|QUOT|#x00022|#34);quotation marks&(quot|QUOT|#x00022|#34);/, 'should escape characters');", - "assert.match(convert(\"Shindler's List\"), /Shindler&(apos|#x00027|#39);s List/, 'should escape characters');", - "assert.match(convert('<>'), /&(lt|LT|#x0003C|#60);&(gt|GT|#x0003E|#62);/, 'should escape characters');", - "assert.strictEqual(convert('abc'), 'abc', 'should handle strings with nothing to escape');" + "assert.match(convert(\"Dolce & Gabbana\"), /Dolce & Gabbana/, 'message: convert(\"Dolce & Gabbana\") should return Dolce &​amp; Gabbana.');", + "assert.match(convert(\"Hamburgers < Pizza < Tacos\"), /Hamburgers < Pizza < Tacos/, 'message: convert(\"Hamburgers < Pizza < Tacos\") should return Hamburgers &​lt; Pizza &​lt; Tacos.');", + "assert.match(convert(\"Sixty > twelve\"), /Sixty > twelve/, 'message: convert(\"Sixty > twelve\") should return Sixty &​gt; twelve.');", + "assert.match(convert('Stuff in \"quotation marks\"'), /Stuff in "quotation marks"/, 'message: convert('Stuff in \"quotation marks\"') should return Stuff in &​quot;quotation marks&​quot;.');", + "assert.match(convert(\"Shindler's List\"), /Shindler's List/, 'message: convert(\"Shindler's List\") should return Shindler&​apos;s List.');", + "assert.match(convert('<>'), /<>/, 'message: convert(\"<>\") should return &​lt;&​gt;.');", + "assert.strictEqual(convert('abc'), 'abc', 'message: convert(\"abc\") should return abc.');" ], "MDNlinks": [ "RegExp", @@ -485,10 +484,10 @@ "spinalCase('This Is Spinal Tap');" ], "tests": [ - "assert.strictEqual(spinalCase('This Is Spinal Tap'), 'this-is-spinal-tap', 'should return spinal case from string with spaces');", - "assert.strictEqual(spinalCase('thisIsSpinalTap'), 'this-is-spinal-tap', 'should return spinal case from string with camel case');", - "assert.strictEqual(spinalCase('The_Andy_Griffith_Show'), 'the-andy-griffith-show', 'should return spinal case from string with snake case');", - "assert.strictEqual(spinalCase('Teletubbies say Eh-oh'), 'teletubbies-say-eh-oh', 'should return spinal case from string with spaces and hyphens');" + "assert.deepEqual(spinalCase(\"This Is Spinal Tap\"), \"this-is-spinal-tap\", 'message: spinalCase(\"This Is Spinal Tap\") should return \"this-is-spinal-tap\".');", + "assert.strictEqual(spinalCase('thisIsSpinalTap'), \"this-is-spinal-tap\", 'message: spinalCase(\"thisIsSpinalTap\") should return \"this-is-spinal-tap\".');", + "assert.strictEqual(spinalCase(\"The_Andy_Griffith_Show\"), \"the-andy-griffith-show\", 'message: spinalCase(\"The_Andy_Griffith_Show\") should return \"the-andy-griffith-show\".');", + "assert.strictEqual(spinalCase(\"Teletubbies say Eh-oh\"), \"teletubbies-say-eh-oh\", 'message: spinalCase(\"Teletubbies say Eh-oh\") should return \"teletubbies-say-eh-oh\".');" ], "MDNlinks": [ "RegExp", @@ -525,12 +524,12 @@ "sumFibs(4);" ], "tests": [ - "assert.deepEqual(typeof(sumFibs(1)), \"number\", \"The result should be a number\");", - "assert.deepEqual(sumFibs(1000), 1785, 'sumFibs(1000) should return 1785');", - "assert.deepEqual(sumFibs(4000000), 4613732, 'sumFibs(4000000) should return 4613732');", - "assert.deepEqual(sumFibs(4), 5, 'sumFibs(4) should return 5');", - "assert.deepEqual(sumFibs(75024), 60696, 'sumFibs(75024) should return 60696');", - "assert.deepEqual(sumFibs(75025), 135721, 'sumFibs(75025) should return 135721');" + "assert(typeof(sumFibs(1)) === \"number\", 'message: sumFibs() should return a number.');", + "assert.deepEqual(sumFibs(1000), 1785, 'message: sumFibs(1000) should return 1785.');", + "assert.deepEqual(sumFibs(4000000), 4613732, 'message: sumFibs(4000000) should return 4613732.');", + "assert.deepEqual(sumFibs(4), 5, 'message: sumFibs(4) should return 5.');", + "assert.deepEqual(sumFibs(75024), 60696, 'message: sumFibs(75024) should return 60696.');", + "assert.deepEqual(sumFibs(75025), 135721, 'message: sumFibs(75025) should return 135721.');" ], "MDNlinks": [ "Remainder" @@ -566,9 +565,9 @@ "sumPrimes(10);" ], "tests": [ - "assert.deepEqual(typeof(sumPrimes(10)), \"number\", \"The result should be a number\");", - "assert.deepEqual(sumPrimes(10), 17, 'sumPrimes(10) should return 17');", - "assert.deepEqual(sumPrimes(977), 73156, 'sumPrimes(977) should return 73156');" + "assert.deepEqual(typeof(sumPrimes(10)), \"number\", 'message: sumPrimes() should return a number.');", + "assert.deepEqual(sumPrimes(10), 17, 'message: sumPrimes(10) should return 17.');", + "assert.deepEqual(sumPrimes(977), 73156, 'message: sumPrimes(977) should return 73156.');" ], "MDNlinks": [ "For Loops", @@ -606,10 +605,10 @@ "smallestCommons([1,5]);" ], "tests": [ - "assert.deepEqual(typeof(smallestCommons([1, 5])), \"number\", \"The result should be a number\");", - "assert.deepEqual(smallestCommons([1, 5]), 60, 'smallestCommons([1, 5]) should return 60');", - "assert.deepEqual(smallestCommons([5, 1]), 60, 'smallestCommons([5, 1]) should return 60');", - "assert.deepEqual(smallestCommons([1, 13]), 360360, 'smallestCommons([1, 13]) should return 360360');" + "assert.deepEqual(typeof(smallestCommons([1, 5])), \"number\", 'message: smallestCommons() should return a number.');", + "assert.deepEqual(smallestCommons([1, 5]), 60, 'message: smallestCommons([1, 5]) should return 60.');", + "assert.deepEqual(smallestCommons([5, 1]), 60, 'message: smallestCommons([5, 1]) should return 60.');", + "assert.deepEqual(smallestCommons([1, 13]), 360360, 'message: smallestCommons([1, 13]) should return 360360.');" ], "MDNlinks": [ "Smallest Common Multiple" @@ -644,8 +643,8 @@ "find([1, 2, 3, 4], function(num){ return num % 2 === 0; });" ], "tests": [ - "assert.strictEqual(find([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, 'should return first found value');", - "assert.strictEqual(find([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, 'should return undefined if not found');" + "assert.strictEqual(find([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, 'message: find([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }) should return 8.');", + "assert.strictEqual(find([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, 'message: find([1, 3, 5, 9], function(num) { return num % 2 === 0; }) should return undefined.');" ], "MDNlinks": [ "Array.some()" @@ -680,10 +679,10 @@ "drop([1, 2, 3], function(n) {return n < 3; });" ], "tests": [ - "assert.deepEqual(drop([1, 2, 3, 4], function(n) {return n>= 3;}), [3, 4], 'drop([1, 2, 3, 4], function(n) {return n>= 3;}) should return [3, 4]');", - "assert.deepEqual(drop([1, 2, 3], function(n) {return n > 0; }), [1, 2, 3], 'drop([1, 2, 3], function(n) {return n > 0; }) should return [1, 2, 3]');", - "assert.deepEqual(drop([1, 2, 3, 4], function(n) {return n > 5;}), [], 'drop([1, 2, 3, 4], function(n) {return n > 5;}) should return []');", - "assert.deepEqual(drop([1, 2, 3, 7, 4], function(n) {return n > 3}), [7, 4], 'drop([1, 2, 3, 7, 4], function(n) {return n>= 3}) should return [7, 4]');" + "assert.deepEqual(drop([1, 2, 3, 4], function(n) {return n>= 3;}), [3, 4], 'message: drop([1, 2, 3, 4], function(n) {return n>= 3;}) should return [3, 4].');", + "assert.deepEqual(drop([1, 2, 3], function(n) {return n > 0; }), [1, 2, 3], 'message: drop([1, 2, 3], function(n) {return n > 0; }) should return [1, 2, 3].');", + "assert.deepEqual(drop([1, 2, 3, 4], function(n) {return n > 5;}), [], 'message: drop([1, 2, 3, 4], function(n) {return n > 5;}) should return [].');", + "assert.deepEqual(drop([1, 2, 3, 7, 4], function(n) {return n > 3}), [7, 4], 'message: drop([1, 2, 3, 7, 4], function(n) {return n>= 3}) should return [7, 4].');" ], "MDNlinks": [ "Arguments object", @@ -719,10 +718,10 @@ "steamroller([1, [2], [3, [[4]]]]);" ], "tests": [ - "assert.deepEqual(steamroller([[['a']], [['b']]]), ['a', 'b'], 'should flatten nested arrays');", - "assert.deepEqual(steamroller([1, [2], [3, [[4]]]]), [1, 2, 3, 4], 'should flatten nested arrays');", - "assert.deepEqual(steamroller([1, [], [3, [[4]]]]), [1, 3, 4], 'should work with empty arrays');", - "assert.deepEqual(steamroller([1, {}, [3, [[4]]]]), [1, {}, 3, 4], 'should work with actual objects');" + "assert.deepEqual(steamroller([[[\"a\"]], [[\"b\"]]]), [\"a\", \"b\"], 'message: steamroller([[[\"a\"]], [[\"b\"]]]) should return [\"a\", \"b\"].');", + "assert.deepEqual(steamroller([1, [2], [3, [[4]]]]), [1, 2, 3, 4], 'message: steamroller([1, [2], [3, [[4]]]]) should return [1, 2, 3, 4].');", + "assert.deepEqual(steamroller([1, [], [3, [[4]]]]), [1, 3, 4], 'message: steamroller([1, [], [3, [[4]]]]) should return [1, 3, 4].');", + "assert.deepEqual(steamroller([1, {}, [3, [[4]]]]), [1, {}, 3, 4], 'message: steamroller([1, {}, [3, [[4]]]]) should return [1, {}, 3, 4].');" ], "MDNlinks": [ "Array.isArray()" @@ -754,11 +753,11 @@ " return str;", "}", "", - "binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111');" + "binaryAgent(\"01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111\");" ], "tests": [ - "assert.deepEqual(binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111'), \"Aren't bonfires fun!?\", \"binaryAgent() should return Aren't bonfires fun!?\");", - "assert.deepEqual(binaryAgent('01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001'), \"I love FreeCodeCamp!\", 'binaryAgent() should return \"I love FreeCodeCamp!\"');" + "assert.deepEqual(binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111'), \"Aren't bonfires fun!?\", 'message: binaryAgent(\"01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111\") should return \"Aren't bonfires fun!?\"');", + "assert.deepEqual(binaryAgent(\"01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001\"), \"I love FreeCodeCamp!\", 'message: binaryAgent(\"01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001\" should return \"I love FreeCodeCamp!\"');" ], "MDNlinks": [ "String.charCodeAt()", @@ -793,12 +792,12 @@ " return pre;", "}", "", - "every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex');" + "every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\");" ], "tests": [ - "assert.strictEqual(every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], 'sex'), true, 'should return true if predicate returns truthy for all elements in the collection');", - "assert.strictEqual(every([{'user': 'Tinky-Winky', 'sex': 'male'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], {'sex': 'female'}), false, 'should return false if predicate returns falsey for any element in the collection');", - "assert.strictEqual(every([{'user': 'Tinky-Winky', 'sex': 'female'}, {'user': 'Dipsy', 'sex': 'male'}, {'user': 'Laa-Laa', 'sex': 'female'}, {'user': 'Po', 'sex': 'female'}], {'sex': 'female'}), false, 'should return false if predicate returns falsey for any element in the collection');" + "assert.strictEqual(every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\"), true, 'message: every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\") should return true.');", + "assert.strictEqual(every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], {\"sex\": \"female\"}), false, 'message: every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], {\"sex\": \"female\"}) should return false.');", + "assert.strictEqual(every([{\"user\": \"Tinky-Winky\", \"sex\": \"female\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], {\"sex\": \"female\"}), false, 'message: every([{\"user\": \"Tinky-Winky\", \"sex\": \"female\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], {\"sex\": \"female\"}) should return false.');" ], "MDNlinks": [ "Object.hasOwnProperty()", @@ -838,11 +837,11 @@ "add(2,3);" ], "tests": [ - "assert.deepEqual(add(2, 3), 5, 'add(2, 3) should return 5');", - "assert.deepEqual(add(2)(3), 5, 'add(2)(3) should return 5');", - "assert.isUndefined(add(\"http://bit.ly/IqT6zt\"), 'add(\"http://bit.ly/IqT6zt\") should return undefined');", - "assert.isUndefined(add(2, \"3\"), 'add(2, \"3\") should return undefined');", - "assert.isUndefined(add(2)([3]), 'add(2)([3]) should return undefined');" + "assert.deepEqual(add(2, 3), 5, 'message: add(2, 3) should return 5.');", + "assert.deepEqual(add(2)(3), 5, 'message: add(2)(3) should return 5.');", + "assert.isUndefined(add(\"http://bit.ly/IqT6zt\"), 'message: add(\"http://bit.ly/IqT6zt\") should return undefined.');", + "assert.isUndefined(add(2, \"3\"), 'message: add(2, \"3\") should return undefined.');", + "assert.isUndefined(add(2)([3]), 'message: add(2)([3]) should return undefined.');" ], "MDNlinks": [ "Global Function Object", diff --git a/challenges/object-oriented-and-functional-programming.json b/challenges/object-oriented-and-functional-programming.json index 2b89e9f6c0..ea84d904db 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\"];", diff --git a/challenges/upper-intermediate-bonfires.json b/challenges/upper-intermediate-bonfires.json index 04d9cc63bb..83e3584e5b 100644 --- a/challenges/upper-intermediate-bonfires.json +++ b/challenges/upper-intermediate-bonfires.json @@ -22,20 +22,13 @@ "bob.getFullName();" ], "tests": [ - "expect(Object.keys(bob).length).to.eql(6);", - "expect(bob instanceof Person).to.be.true;", - "expect(bob.firstName).to.be.undefined();", - "expect(bob.lastName).to.be.undefined();", - "expect(bob.getFirstName()).to.eql('Bob');", - "expect(bob.getLastName()).to.eql('Ross');", - "expect(bob.getFullName()).to.eql('Bob Ross');", - "bob.setFirstName('Happy');", - "expect(bob.getFirstName()).to.eql('Happy');", - "bob.setLastName('Trees');", - "expect(bob.getLastName()).to.eql('Trees');", - "bob.setFullName('George Carlin');", - "expect(bob.getFullName()).to.eql('George Carlin');", - "bob.setFullName('Bob Ross');" + "assert.deepEqual(Object.keys(bob).length, 6, 'message: Object.keys(bob).length should return 6.');", + "assert.deepEqual(bob instanceof Person, true, 'message: bob instanceof Person should return true.');", + "assert.deepEqual(bob.firstName, undefined, 'message: bob.firstName should return undefined.');", + "assert.deepEqual(bob.lastName, undefined, 'message: bob.lastName should return undefined.');", + "assert.deepEqual(bob.getFirstName(), 'Bob', 'message: bob.getFirstName() should return \"Bob\".');", + "assert.deepEqual(bob.getLastName(), 'Ross', 'message: bob.getLastName() should return \"Ross\".');", + "assert.deepEqual(bob.getFullName(), 'Bob Ross', 'message: bob.getFullName() should return \"Bob Ross\".');" ], "MDNlinks": [ "Closures", @@ -77,8 +70,8 @@ "orbitalPeriod([{name : \"sputnik\", avgAlt : 35873.5553}]);" ], "tests": [ - "expect(orbitalPeriod([{name : \"sputnik\", avgAlt : 35873.5553}])).to.eqls([{name: \"sputnik\", orbitalPeriod: 86400}]);", - "expect(orbitalPeriod([{name: \"iss\", avgAlt: 413.6}, {name: \"hubble\", avgAlt: 556.7}, {name: \"moon\", avgAlt: 378632.553}])).to.eqls([{name : \"iss\", orbitalPeriod: 5557}, {name: \"hubble\", orbitalPeriod: 5734}, {name: \"moon\", orbitalPeriod: 2377399}]);" + "assert.deepEqual(orbitalPeriod([{name : \"sputnik\", avgAlt : 35873.5553}]), [{name: \"sputnik\", orbitalPeriod: 86400}], 'message: orbitalPeriod([{name : \"sputnik\", avgAlt : 35873.5553}]) should return [{name: \"sputnik\", orbitalPeriod: 86400}].');", + "assert.deepEqual(orbitalPeriod([{name: \"iss\", avgAlt: 413.6}, {name: \"hubble\", avgAlt: 556.7}, {name: \"moon\", avgAlt: 378632.553}]), [{name : \"iss\", orbitalPeriod: 5557}, {name: \"hubble\", orbitalPeriod: 5734}, {name: \"moon\", orbitalPeriod: 2377399}], 'message: orbitalPeriod([{name: \"iss\", avgAlt: 413.6}, {name: \"hubble\", avgAlt: 556.7}, {name: \"moon\", avgAlt: 378632.553}]) should return [{name : \"iss\", orbitalPeriod: 5557}, {name: \"hubble\", orbitalPeriod: 5734}, {name: \"moon\", orbitalPeriod: 2377399}].');" ], "MDNlinks": [ "Math.pow()" @@ -114,11 +107,11 @@ "pairwise([1,4,2,3,0,5], 7);" ], "tests": [ - "expect(pairwise([1, 4, 2, 3, 0, 5], 7)).to.equal(11);", - "expect(pairwise([1, 3, 2, 4], 4)).to.equal(1);", - "expect(pairwise([1,1,1], 2)).to.equal(1);", - "expect(pairwise([0, 0, 0, 0, 1, 1], 1)).to.equal(10);", - "expect(pairwise([], 100)).to.equal(0);" + "assert.deepEqual(pairwise([1, 4, 2, 3, 0, 5], 7), 11, 'message: pairwise([1, 4, 2, 3, 0, 5], 7) should return 11.');", + "expect(pairwise([1, 3, 2, 4], 4), 1, 'message: pairwise([1, 3, 2, 4], 4), 1 should return 1.');", + "expect(pairwise([1,1,1], 2), 1, 'message: pairwise([1,1,1], 2) should return 1.');", + "expect(pairwise([0, 0, 0, 0, 1, 1], 1), 10, 'message: pairwise([0, 0, 0, 0, 1, 1], 1) should return 10.');", + "expect(pairwise([], 100), 0, 'message: pairwise([], 100) should return 0.');" ], "MDNlinks": [ "Array.reduce()"