mirror of https://github.com/01-edu/public.git
Clement Denis
4 years ago
20 changed files with 274 additions and 155 deletions
@ -1,26 +1,26 @@
|
||||
[ |
||||
{ |
||||
"description": "add2, sub2, mult2 and div2 are defined and are functions", |
||||
"code": "if (typeof add2 === 'undefined') {\n throw Error(\n `You didn't even define the function add2... make it better! reread the lesson...`,\n )\n}\nif (typeof add2 != 'function') {\n throw Error('add2 must be a function')\n}\n\nif (typeof sub2 === 'undefined') {\n throw Error(\n `You didn't even define the function sub2... make it better! reread the lesson...`,\n )\n}\nif (typeof sub2 != 'function') {\n throw Error('sub2 must be a function')\n}\n\nif (typeof mult2 === 'undefined') {\n throw Error(\n `You didn't even define the function mult2... make it better! reread the lesson...`,\n )\n}\nif (typeof mult2 != 'function') {\n throw Error('mult2 must be a function')\n}\n\nif (typeof div2 === 'undefined') {\n throw Error(\n `You didn't even define the function div2... make it better! reread the lesson...`,\n )\n}\nif (typeof div2 != 'function') {\n throw Error('div2 must be a function')\n}" |
||||
"description": "add2 is defined and are functions", |
||||
"code": "equal(typeof add2, 'function')" |
||||
}, |
||||
{ |
||||
"description": "add2, sub2, mult2 and div2 have 2 arguments", |
||||
"code": "if (add2.length != 2) {\n throw Error('You need 2 arguments for this function!(add2)')\n}\nif (sub2.length != 2) {\n throw Error('You need 2 arguments for this function!(sub2)')\n}\nif (mult2.length != 2) {\n throw Error('You need 2 arguments for this function!(mult2)')\n}\nif (div2.length != 2) {\n throw Error('You need 2 arguments for this function!(div2)')\n}" |
||||
"description": "add2 takes 2 arguments", |
||||
"code": "equal(add2.length, 2)" |
||||
}, |
||||
{ |
||||
"description": "add2 returns the right results", |
||||
"code": "equal(add2(1, 1), 2)\nequal(add2(1, 2), 3)\nequal(add2(2, 2), 4)\nequal(add2(2, 3), 5)" |
||||
}, |
||||
{ |
||||
"description": "sub2 returns the right results", |
||||
"code": "equal(sub2(1, 1), 0)\nequal(sub2(2, 1), 1)\nequal(sub2(3, 1), 2)\nequal(sub2(4, 1), 3)" |
||||
"description": "sub2 is defined and are functions", |
||||
"code": "equal(typeof sub2, 'function')" |
||||
}, |
||||
{ |
||||
"description": "mult2 returns the right results", |
||||
"code": "equal(mult2(1, 1), 1)\nequal(mult2(1, 2), 2)\nequal(mult2(2, 2), 4)\nequal(mult2(2, 3), 6)" |
||||
"description": "sub2 takes 2 arguments", |
||||
"code": "equal(sub2.length, 2)" |
||||
}, |
||||
{ |
||||
"description": "div2 returns the right results", |
||||
"code": "equal(div2(1, 1), 1)\nequal(div2(2, 1), 2)\nequal(div2(2, 2), 1)\nequal(div2(6, 2), 3)" |
||||
"description": "sub2 returns the right results", |
||||
"code": "equal(sub2(1, 1), 0)\nequal(sub2(2, 1), 1)\nequal(sub2(3, 1), 2)\nequal(sub2(-4, -7), 3)" |
||||
} |
||||
] |
@ -1,26 +1,30 @@
|
||||
[ |
||||
{ |
||||
"description": "battleCry is a defined and is a function", |
||||
"code": "if (typeof battleCry === 'undefined') {\n throw Error(\n `You didn't even define the function battleCry... make it better! reread the lesson...`,\n )\n}\n\nif (typeof battleCry != 'function') {\n throw Error('battleCry must be a function')\n}" |
||||
"description": "battleCry is defined and is a function", |
||||
"code": "equal(typeof battleCry, 'function')" |
||||
}, |
||||
{ |
||||
"description": "secretOrders is a defined and is a function", |
||||
"code": "if (typeof secretOrders === 'undefined') {\n throw Error(\n `You didn't even define the function secretOrders... make it better! reread the lesson...`,\n )\n}\n\nif (typeof secretOrders != 'function') {\n throw Error('secretOrders must be a function')\n}" |
||||
"description": "secretOrders is defined and is a function", |
||||
"code": "equal(typeof secretOrders, 'function')" |
||||
}, |
||||
{ |
||||
"description": "battleCry has one and only one argument", |
||||
"code": "if (battleCry.length != 1) {\n throw Error('You must use 1 argument for this function, and only one!')\n}" |
||||
"code": "equal(battleCry.length, 1)" |
||||
}, |
||||
{ |
||||
"description": "secretOrders has one and only one argument", |
||||
"code": "if (secretOrders.length != 1) {\n throw Error('You must use 1 argument for this function, and only one!')\n}" |
||||
"code": "equal(secretOrders.length, 1)" |
||||
}, |
||||
{ |
||||
"description": "battleCry shouts properly", |
||||
"code": "const args = saveArguments(console, 'log')\nlet orders = {\n shouted: ['attack!', 'you shall not pass!', 'for the horde!'],\n secrets: ['ExEcutE Order 66', 'SILENCE', 'This Is The WAY'],\n}\n\n// Your code\n\norders.shouted.map((el) => battleCry(el))\n\nconst loggedValues = args.flat().join(' ')\nif (!loggedValues.includes('ATTACK!')) {\n throw Error(`battleCry('attack!') is not SHOUTING: ATTACK!`)\n}\nif (!loggedValues.includes('YOU SHALL NOT PASS!')) {\n throw Error(\n `battleCry(you shall not pass!) is not SHOUTING: YOU SHALL NOT PASS!`,\n )\n}\nif (!loggedValues.includes('FOR THE HORDE!')) {\n throw Error(`battleCry('for the horde!') is not SHOUTING: FOR THE HORDE!`)\n}" |
||||
"code": "const args = saveArguments(console, 'log')\n// Your code\n\nbattleCry('attack')\nbattleCry('you shall not pass!')\n\nequal(args.flat(), ['ATTACK', 'YOU SHALL NOT PASS!'])" |
||||
}, |
||||
{ |
||||
"description": "secretOrders whispers properly", |
||||
"code": "const args = saveArguments(console, 'log')\nlet orders = {\n shouted: ['attack!', 'you shall not pass!', 'for the horde!'],\n secrets: ['ExEcutE Order 66', 'SILENCE', 'This Is The WAY'],\n}\n\n// Your code\n\norders.secrets.map((el) => secretOrders(el))\n\nconst loggedValues = args.flat().join(' ')\nif (!loggedValues.includes('execute order 66')) {\n throw Error(\n `secretOrders('ExEcutE Order 66') is not whispering: execute order 66 `,\n )\n}\nif (!loggedValues.includes('silence')) {\n throw Error(`secretOrders('SILENCE') is not whispering: silence `)\n}\nif (!loggedValues.includes('this is the way')) {\n throw Error(\n `secretOrders('This Is The WAY') is not whispering: this is the way `,\n )\n}" |
||||
"code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nsecretOrders('ExEcutE Order 66')\nsecretOrders('SILENCE')\n\nequal(args.flat(), ['execute order 66', 'silence'])" |
||||
}, |
||||
{ |
||||
"description": "We can call both functions", |
||||
"code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nsecretOrders('This Is The WAY')\nbattleCry('for the horde !')\n\nequal(args.flat(), ['this is the way', 'FOR THE HORDE !'])" |
||||
} |
||||
] |
@ -1,22 +1,26 @@
|
||||
[ |
||||
{ |
||||
"description": "addAll, subAll, multAll and divAll are defined and are functions", |
||||
"code": "if (typeof addAll === 'undefined') {\n throw Error(\n `You didn't even define the function addAll... make it better! reread the lesson...`,\n )\n}\nif (typeof addAll != 'function') {\n throw Error('addAll must be a function')\n}\n\nif (typeof subAll === 'undefined') {\n throw Error(\n `You didn't even define the function subAll... make it better! reread the lesson...`,\n )\n}\nif (typeof subAll != 'function') {\n throw Error('subAll must be a function')\n}\n\nif (typeof multAll === 'undefined') {\n throw Error(\n `You didn't even define the function multAll... make it better! reread the lesson...`,\n )\n}\nif (typeof multAll != 'function') {\n throw Error('multAll must be a function')\n}\n\nif (typeof divAll === 'undefined') {\n throw Error(\n `You didn't even define the function divAll... make it better! reread the lesson...`,\n )\n}\nif (typeof divAll != 'function') {\n throw Error('divAll must be a function')\n}" |
||||
"description": "countArgs is defined and are functions", |
||||
"code": "equal(typeof countArgs, 'function')" |
||||
}, |
||||
{ |
||||
"description": "addAll returns the right results", |
||||
"code": "equal(addAll(1, 1), 2)\nequal(addAll(1, 2, 3), 6)\nequal(addAll(2, 2, 4, 10), 18)\nequal(addAll(2, 3, 3, 5, 5, 10), 28)" |
||||
"description": "countArgs returns the right results for 2 arguments", |
||||
"code": "equal(countArgs(1, 1), 2)" |
||||
}, |
||||
{ |
||||
"description": "subAll returns the right results", |
||||
"code": "equal(subAll(1, 1), 0)\nequal(subAll(2, 1, 1, -1), 1)\nequal(subAll(10, 3, 1, 4), 2)\nequal(subAll(11, 4, 1, 3, 3, 3), -3)" |
||||
"description": "countArgs returns the right results for 3 arguments", |
||||
"code": "equal(countArgs(1, 2, 3), 3)" |
||||
}, |
||||
{ |
||||
"description": "multAll returns the right results", |
||||
"code": "equal(multAll(1, 1), 1)\nequal(multAll(1, 2, 10), 20)\nequal(multAll(2, 2, 10, 10), 400)\nequal(multAll(2, 3, -2, 10, 10), -1200)" |
||||
"description": "countArgs returns the right results for 4 arguments", |
||||
"code": "equal(countArgs(2, 2, 4, 10), 4)" |
||||
}, |
||||
{ |
||||
"description": "divAll returns the right results", |
||||
"code": "equal(divAll(1, 1), 1)\nequal(divAll(2, 1, 1), 2)\nequal(divAll(100, 2, 2, 5), 5)\nequal(divAll(1000, 10, 5, 4, 1), 5)" |
||||
"description": "countArgs returns the right results for 6 arguments", |
||||
"code": "equal(countArgs(2, 3, 3, 5, 5, 10), 6)" |
||||
}, |
||||
{ |
||||
"description": "countArgs can count a lot of arguments", |
||||
"code": "equal(countArgs(...Array(999).fill()), 999)" |
||||
} |
||||
] |
@ -1,26 +1,46 @@
|
||||
[ |
||||
{ |
||||
"description": "happy is defined and is a function", |
||||
"code": "if (typeof happy === 'undefined') {\n throw Error(\n `You didn't even define the function happy... make it better! reread the lesson...`,\n )\n}\nif (typeof happy != 'function') {\n throw Error('happy must be a function')\n}" |
||||
"code": "equal(typeof happy, 'function')" |
||||
}, |
||||
{ |
||||
"description": "happy has 1 argument", |
||||
"code": "if (happy.length != 1) {\n throw Error('You need 1 argument for this function!')\n}" |
||||
"code": "equal(happy.length, 1)" |
||||
}, |
||||
{ |
||||
"description": "happy is smiling right.", |
||||
"code": "equal(happy('Are you happy?'), true)\nequal(happy('Happy?'), true)\nequal(happy('Are you sad?'), false)\nequal(happy('happy!'), false)\nequal(happy('Happy! are we not?'), true)" |
||||
"description": "very happy.", |
||||
"code": "equal(happy('Are you happy ?'), true)" |
||||
}, |
||||
{ |
||||
"description": "very happy.", |
||||
"code": "equal(happy('Happy ?'), true)" |
||||
}, |
||||
{ |
||||
"description": "very happy.", |
||||
"code": "equal(happy('Happy ! are we not ?'), true)" |
||||
}, |
||||
{ |
||||
"description": "not happy.", |
||||
"code": "equal(happy('Are you sad ?'), false)" |
||||
}, |
||||
{ |
||||
"description": "not happy.", |
||||
"code": "equal(happy('happy !'), false)" |
||||
}, |
||||
{ |
||||
"description": "not happy.", |
||||
"code": "equal(happy('Was I happy ? nope.'), false)" |
||||
}, |
||||
{ |
||||
"description": "happy has no curly braces {}.", |
||||
"code": "if (happy.toString().includes('{')) {\n throw Error('No curly braces {} ! ')\n}\nif (happy.toString().includes('}')) {\n throw Error('No curly braces {} ! ')\n}" |
||||
"code": "if (/\\{.*\\}/.test(happy)) {\n throw Error('No curly braces {} ! ')\n}" |
||||
}, |
||||
{ |
||||
"description": "happy has no keyword return.", |
||||
"code": "if (happy.toString().includes('return')) {\n throw Error('No keyword return allowed ! ')\n}" |
||||
"code": "if (String(happy).includes('return')) {\n throw Error('No keyword return allowed ! ')\n}" |
||||
}, |
||||
{ |
||||
"description": "happy has no keyword if.", |
||||
"code": "if (happy.toString().includes('if')) {\n throw Error('No keyword if allowed ! ')\n}" |
||||
"code": "if (String(happy).includes('if')) {\n throw Error('No keyword if allowed ! ')\n}" |
||||
} |
||||
] |
@ -1,14 +1,30 @@
|
||||
[ |
||||
{ |
||||
"description": "shaker is a defined and is a function", |
||||
"code": "if (typeof shaker === 'undefined') {\n throw Error(\n `You didn't even define the function shaker... make it better! reread the lesson...`,\n )\n}\n\nif (typeof shaker != 'function') {\n throw Error('shaker must be a function')\n}" |
||||
"description": "shaker is defined and is a function", |
||||
"code": "equal(typeof shaker, 'function')" |
||||
}, |
||||
{ |
||||
"description": "shaker has 3 arguments", |
||||
"code": "if (shaker.length != 3) {\n throw Error('You need 3 arguments for this function!')\n}" |
||||
"code": "equal(shaker.length, 3)" |
||||
}, |
||||
{ |
||||
"description": "shaker can make a cocktail.", |
||||
"code": "equal(shaker(1, 'strawberry', true), '1 strawberry cocktail')" |
||||
}, |
||||
{ |
||||
"description": "shaker can make a milkshake.", |
||||
"code": "equal(shaker(1, 'strawberry', false), '1 strawberry milkshake')" |
||||
}, |
||||
{ |
||||
"description": "shaker can make multiple cocktails.", |
||||
"code": "equal(shaker(7, 'banana', true), '7 banana cocktails')" |
||||
}, |
||||
{ |
||||
"description": "shaker can make multiple milkshakes.", |
||||
"code": "equal(shaker(22, 'banana', false), '22 banana milkshakes')" |
||||
}, |
||||
{ |
||||
"description": "shaker is shakin it right.", |
||||
"code": "equal(shaker(1, 'strawberry', true), '1 strawberry cocktail')\nequal(shaker(1, 'vanilla', true), '1 vanilla cocktail')\nequal(shaker(1, 'mango', true), '1 mango cocktail')\nequal(shaker(1, 'strawberry', false), '1 strawberry milkshake')\n\nequal(shaker(2, 'banana', true), '2 banana cocktails')\nequal(shaker(2, 'chocolate', false), '2 chocolate milkshakes')\nequal(shaker(2, 'vanilla', false), '2 vanilla milkshakes')\nequal(shaker(2, 'strawberry', false), '2 strawberry milkshakes')" |
||||
"code": "equal(shaker(1, 'vanilla', true), '1 vanilla cocktail')\nequal(shaker(1, 'mango', true), '1 mango cocktail')\nequal(shaker(2, 'banana', true), '2 banana cocktails')\nequal(shaker(2, 'chocolate', false), '2 chocolate milkshakes')\nequal(shaker(2, 'vanilla', false), '2 vanilla milkshakes')\nequal(shaker(2, 'strawberry', false), '2 strawberry milkshakes')" |
||||
} |
||||
] |
@ -1,6 +1,22 @@
|
||||
[ |
||||
{ |
||||
"description": "Not implemented", |
||||
"code": "throw Error('oops')" |
||||
"description": "Weak candidates must stay on earth", |
||||
"code": "let candidate = { noFamily: true, physicalAptitudes: 5 }\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['earth'])" |
||||
}, |
||||
{ |
||||
"description": "Strong candadidates without families can go on mars", |
||||
"code": "let candidate = { noFamily: true, physicalAptitudes: 99 }\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['mars'])" |
||||
}, |
||||
{ |
||||
"description": "Strong candadidates with a family can go to the moon", |
||||
"code": "let candidate = { noFamily: false, physicalAptitudes: 87 }\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['moon'])" |
||||
}, |
||||
{ |
||||
"description": "Even barely strong enough candidates can make it", |
||||
"code": "let candidate = { noFamily: false, physicalAptitudes: 80 }\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['moon'])" |
||||
}, |
||||
{ |
||||
"description": "But almost strong enough candidates can not", |
||||
"code": "let candidate = { noFamily: true, physicalAptitudes: 79 }\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['earth'])" |
||||
} |
||||
] |
@ -1,26 +1,26 @@
|
||||
[ |
||||
{ |
||||
"description": "duos is a defined and is a function", |
||||
"code": "if (typeof duos === 'undefined') {\n throw Error(\n `You didn't even define the function duos... make it better! reread the lesson...`,\n )\n}\n\nif (typeof duos != 'function') {\n throw Error('duos must be a function')\n}" |
||||
"description": "duos is defined and is a function", |
||||
"code": "equal(typeof duos, 'function')" |
||||
}, |
||||
{ |
||||
"description": "duos has two arguments", |
||||
"code": "if (duos.length != 2) {\n throw Error('You need two arguments for this function!')\n}" |
||||
"description": "duos takes two arguments", |
||||
"code": "equal(duos.length, 2)" |
||||
}, |
||||
{ |
||||
"description": "duos combines properly", |
||||
"code": "const args = saveArguments(console, 'log')\nlet combinations2 = [\n ['Batman', 'Robin'],\n ['Pinky', 'The Brain'],\n ['Bonnie', 'Clyde'],\n ['Mr.', 'Mrs.Smith'],\n]\n\n// Your code\n\ncombinations2.map((el) => duos(el[0], el[1]))\n\nconst loggedValues = args.flat().join(' ')\nif (!loggedValues.includes('Batman and Robin!')) {\n throw Error(`duos('Batman', 'Robin') is not combining: Batman and Robin!`)\n}\nif (!loggedValues.includes('Pinky and The Brain!')) {\n throw Error(\n `duos('Pinky', 'The Brain') is not combining: Pinky and The Brain!`,\n )\n}\nif (!loggedValues.includes('Bonnie and Clyde!')) {\n throw Error(`duos('Bonnie', 'Clyde') is not combining: Bonnie and Clyde!`)\n}\nif (!loggedValues.includes('Mr. and Mrs.Smith!')) {\n throw Error(`duos('Mr.', 'Mrs.Smith') is not combining: Mr. and Mrs.Smith!`)\n}" |
||||
"description": "duos logs the expected result", |
||||
"code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nduos('Batman', 'Robin')\nduos('Pinky', 'The Brain')\nduos('Bonnie', 'Clyde')\nduos('Mr.', 'Mrs.Smith')\n\nequal(\n args.map(arg => arg.join(' ')),\n [\n 'Batman and Robin !',\n 'Pinky and The Brain !',\n 'Bonnie and Clyde !',\n 'Mr. and Mrs.Smith !',\n ],\n)" |
||||
}, |
||||
{ |
||||
"description": "duosWork is a defined and is a function", |
||||
"code": "if (typeof duosWork === 'undefined') {\n throw Error(\n `You didn't even define the function duosWork... make it better! reread the lesson...`,\n )\n}\n\nif (typeof duosWork != 'function') {\n throw Error('duosWork must be a function')\n}" |
||||
"description": "duosWork is defined and is a function", |
||||
"code": "equal(typeof duosWork, 'function')" |
||||
}, |
||||
{ |
||||
"description": "duosWork has three arguments", |
||||
"code": "if (duosWork.length != 3) {\n throw Error('You need three arguments for this function!')\n}" |
||||
"description": "duosWork takes three arguments", |
||||
"code": "equal(duosWork.length, 3)" |
||||
}, |
||||
{ |
||||
"description": "duosWork combines properly", |
||||
"code": "const args = saveArguments(console, 'log')\nlet combinations3 = [\n ['Batman', 'Robin', 'protect Gotham'],\n ['Pinky', 'The Brain', 'want to conquer the world'],\n ['Bonnie', 'Clyde', 'escape the Police'],\n ['Mr.', 'Mrs.Smith', 'are the greatest spy couple'],\n]\n\n// Your code\n\ncombinations3.map((el) => duosWork(el[0], el[1], el[2]))\n\nconst loggedValues = args.flat().join(' ')\nif (!loggedValues.includes('Batman and Robin protect Gotham!')) {\n throw Error(\n `duosWork('Batman', 'Robin', 'protect Gotham') is not combining: Batman and Robin protect Gotham!`,\n )\n}\nif (!loggedValues.includes('Pinky and The Brain want to conquer the world!')) {\n throw Error(\n `duosWork('Pinky', 'The Brain', 'want to conquer the world') is not combining: Pinky and The Brain want to conquer the world!`,\n )\n}\nif (!loggedValues.includes('Bonnie and Clyde escape the Police!')) {\n throw Error(\n `duosWork('Bonnie', 'Clyde', 'escape the Police') is not combining: Bonnie and Clyde escape the Police!`,\n )\n}\nif (!loggedValues.includes('Mr. and Mrs.Smith are the greatest spy couple!')) {\n throw Error(\n `duosWork('Mr.', 'Mrs.Smith', 'are the greatest spy couple') is not combining: Mr. and Mrs.Smith are the geatest spy couple!`,\n )\n}" |
||||
"description": "duosWork logs the expected result", |
||||
"code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nduosWork('Batman', 'Robin', 'protect Gotham')\nduosWork('Pinky', 'The Brain', 'want to conquer the world')\nduosWork('Bonnie', 'Clyde', 'escape the Police')\nduosWork('Mr.', 'Mrs.Smith', 'are the greatest spy couple')\n\nequal(\n args.map(arg => arg.join(' ')),\n [\n 'Batman and Robin protect Gotham !',\n 'Pinky and The Brain want to conquer the world !',\n 'Bonnie and Clyde escape the Police !',\n 'Mr. and Mrs.Smith are the greatest spy couple !',\n ],\n)" |
||||
} |
||||
] |
@ -1,26 +1,22 @@
|
||||
[ |
||||
{ |
||||
"description": "whatIsMyPurpose is defined and is a function", |
||||
"code": "let dialogue = {\n myQuestion: 'What is my purpose?',\n \"Rick's answer\": 'You pass butter.',\n}\n\n// Your code\n\nif (typeof whatIsMyPurpose === 'undefined') {\n throw Error(\n `You didn't even define the function whatIsMyPurpose... make it better! reread the lesson...`,\n )\n}\n\nif (typeof whatIsMyPurpose != 'function') {\n throw Error('whatIsMyPurpose must be a function')\n}" |
||||
"description": "ask is defined and is a function", |
||||
"code": "equal(typeof ask, 'function')" |
||||
}, |
||||
{ |
||||
"description": "theAnswer is defined and is a function", |
||||
"code": "let dialogue = {\n myQuestion: 'What is my purpose?',\n \"Rick's answer\": 'You pass butter.',\n}\n\n// Your code\n\nif (typeof theAnswer === 'undefined') {\n throw Error(\n `You didn't even define the function theAnswer... make it better! reread the lesson...`,\n )\n}\n\nif (typeof theAnswer != 'function') {\n throw Error('theAnswer must be a function')\n}" |
||||
"description": "reply is defined and is a function", |
||||
"code": "equal(typeof reply, 'function')" |
||||
}, |
||||
{ |
||||
"description": "whatIsMyPurpose has no arguments", |
||||
"code": "let dialogue = {\n myQuestion: 'What is my purpose?',\n \"Rick's answer\": 'You pass butter.',\n}\n\n// Your code\n\nif (whatIsMyPurpose.length > 0) {\n throw Error('No arguments allowed for this function! You do not need them!')\n}" |
||||
"description": "ask works and is called", |
||||
"code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['What is my purpose ?'])" |
||||
}, |
||||
{ |
||||
"description": "theAnswer has no arguments", |
||||
"code": "let dialogue = {\n myQuestion: 'What is my purpose?',\n \"Rick's answer\": 'You pass butter.',\n}\n\n// Your code\n\nif (theAnswer.length > 0) {\n throw Error('No arguments allowed for this function! You do not need them!')\n}" |
||||
"description": "reply works and is called too", |
||||
"code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args, [['What is my purpose ?'], ['You pass butter.']])" |
||||
}, |
||||
{ |
||||
"description": "whatIsMyPurpose works and is called", |
||||
"code": "const args = saveArguments(console, 'log')\nlet dialogue = {\n myQuestion: 'What is my purpose?',\n \"Rick's answer\": 'You pass butter.',\n}\n\n// Your code\n\nwhatIsMyPurpose()\n\nconst loggedValues = args.flat().join(' ')\nif (!loggedValues.includes('What is my purpose?')) {\n throw Error('you must log the value of the key: myQuestion')\n}\nconst functionCalls = args.flat().filter((el) => el === 'What is my purpose?')\n .length\nif (functionCalls != 2) {\n throw Error(`you must call the function whatIsMyPurpose once\"`)\n}" |
||||
}, |
||||
{ |
||||
"description": "theAnswer works and is called", |
||||
"code": "const args = saveArguments(console, 'log')\nlet dialogue = {\n myQuestion: 'What is my purpose?',\n \"Rick's answer\": 'You pass butter.',\n}\n\n// Your code\n\ntheAnswer()\n\nconst loggedValues = args.flat().join(' ')\nif (!loggedValues.includes('You pass butter.')) {\n throw Error(`you must log the value of the key: \"Rick's answer\"`)\n}\nconst functionCalls = args.flat().filter((el) => el === 'You pass butter.')\n .length\nif (functionCalls != 2) {\n throw Error(`you must call the function theAnswer once\"`)\n}" |
||||
"description": "calling reply and ask again relog the text.", |
||||
"code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[1], ['You pass butter.'])" |
||||
} |
||||
] |
@ -1,14 +1,14 @@
|
||||
[ |
||||
{ |
||||
"description": "passButter is a defined and is a function", |
||||
"code": "if (typeof passButter === 'undefined') {\n throw Error(\n `You didn't even define the function passButter... make it better! reread the lesson...`,\n )\n}\n\nif (typeof passButter != 'function') {\n throw Error('passButter must be a function')\n}" |
||||
"description": "passButter is defined and is a function", |
||||
"code": "equal(typeof passButter, 'function')" |
||||
}, |
||||
{ |
||||
"description": "passButter has no arguments", |
||||
"code": "if (passButter.length != 0) {\n throw Error('You need no arguments for this function!')\n}" |
||||
"description": "passButter returns The butter properly", |
||||
"code": "equal(passButter(), 'The butter')" |
||||
}, |
||||
{ |
||||
"description": "passButter returns The butter properly", |
||||
"code": "// Your code\n\nlet theTable = passButter()\n\nif (theTable != 'The butter') {\n throw Error(`passButter() did not return 'The butter'`)\n}" |
||||
"description": "calling passButter mulitple time should always return the butter", |
||||
"code": "equal(\n [passButter(), passButter(), passButter()],\n ['The butter', 'The butter', 'The butter'],\n)" |
||||
} |
||||
] |
@ -1,3 +1,13 @@
|
||||
## extremes |
||||
## Extremes |
||||
|
||||
find the bigest and smallest number of the list |
||||
### Instructions |
||||
|
||||
Create a function `extreme` that given an array of number find the bigest and |
||||
smallest number of the array |
||||
|
||||
**Examples:** |
||||
|
||||
```js |
||||
extreme([-1, 0, 10, 5]) // -> { bigest: 10, smallest: -1 } |
||||
extreme([22, 7, 32, 99, 54]) // -> { bigest: 99, smallest: 7 } |
||||
``` |
||||
|
@ -1,3 +1,45 @@
|
||||
## Go to 11 |
||||
|
||||
### Looping with the `while` keyword |
||||
|
||||
Loops are one of the last missing basic blocks of programing left to learn, |
||||
let's see it in action: |
||||
|
||||
```js |
||||
while (count < 30) { |
||||
// Code to be repeated here |
||||
} |
||||
``` |
||||
|
||||
As you can see, it is exactly like an `if`, we have a scope `{}` and a |
||||
`(condition)` just a new keyword. |
||||
|
||||
Unlike the `if` however, the code inside the scope will be executed as long as |
||||
the condition is `true` |
||||
|
||||
It is easy to get stuck in an never ending loop as if your condition is never |
||||
`false` you will always be stuck in a loop |
||||
|
||||
As such it is common to have some kind of iteration inside our looping code: |
||||
|
||||
```js |
||||
while (count < 30) { |
||||
count = count + 1 |
||||
} |
||||
``` |
||||
|
||||
Now everytime our code is executed, the value of `count` will be `incremented` |
||||
by `1`, until it reach `30` and stop. |
||||
|
||||
> If your code is stuck in an infinite loop, you can do a Ctrl+C shortcut in the |
||||
> terminal to interrupt the code |
||||
|
||||
### Instructions |
||||
|
||||
Write a function `goTo11` that takes a `start` number argument and call |
||||
`console.log` on each numbers from the `start` (included) up to and including |
||||
`11`. |
||||
|
||||
If the `start` is higher than `11` your function must do nothing. |
||||
|
||||
[These go to Eleven... — "This is Spinal Tap" (1984)](https://www.youtube.com/watch?v=hW008FcKr3Q) |
||||
|
Loading…
Reference in new issue