Browse Source

discovery-piscine: update exercises and test

pull/768/head
Clement Denis 3 years ago
parent
commit
3cdfd1a34c
  1. 26
      js/tests/a-new-purpose.json
  2. 26
      js/tests/a-winning-argument.json
  3. 22
      js/tests/give-it-a-rest.json
  4. 26
      js/tests/happy.json
  5. 14
      js/tests/level-up.json
  6. 22
      js/tests/my-house.json
  7. 4
      js/tests/parenting.json
  8. 22
      js/tests/phant0m-writ3r.json
  9. 46
      js/tests/rest-in-peace.json
  10. 22
      js/tests/security.json
  11. 46
      js/tests/seeker-of-truth.json
  12. 22
      js/tests/special-promo.json
  13. 30
      js/tests/spread-the-word.json
  14. 18
      js/tests/time-to-pay.json
  15. 6
      js/tests/to-infinity-and-beyond.json
  16. 26
      js/tests/two-can-play-that-game.json
  17. 18
      js/tests/virus19.json
  18. 18
      js/tests/what-else.json
  19. 26
      js/tests/what-is-my-purpose.json
  20. 14
      js/tests/you-pass-butter.json
  21. 53
      subjects/a-new-purpose/README.md
  22. 71
      subjects/a-winning-argument/README.md
  23. 2
      subjects/access/README.md
  24. 10
      subjects/all-caps/README.md
  25. 2
      subjects/alter-ego/README.md
  26. 2
      subjects/anything-to-declare/README.md
  27. 6
      subjects/cut/README.md
  28. 23
      subjects/give-it-a-rest/README.md
  29. 22
      subjects/griswold-the-blacksmith/README.md
  30. 31
      subjects/happy/README.md
  31. 4
      subjects/keep/README.md
  32. 52
      subjects/level-up/README.md
  33. 11
      subjects/maximus/README.md
  34. 64
      subjects/my-house/README.md
  35. 2
      subjects/notorious/README.md
  36. 2
      subjects/parenting/README.md
  37. 27
      subjects/phant0m-writ3r/README.md
  38. 2
      subjects/pop-art/README.md
  39. 2
      subjects/ratchet-clap/README.md
  40. 2
      subjects/redeclaration-of-love/README.md
  41. 42
      subjects/rest-in-peace/README.md
  42. 17
      subjects/security/README.md
  43. 25
      subjects/seeker-of-truth/README.md
  44. 27
      subjects/special-promo/README.md
  45. 19
      subjects/spread-the-word/README.md
  46. 2
      subjects/the-true-king/README.md
  47. 26
      subjects/time-to-pay/README.md
  48. 43
      subjects/to-infinity-and-beyond/README.md
  49. 81
      subjects/two-can-play-that-game/README.md
  50. 33
      subjects/virus19/README.md
  51. 26
      subjects/what-else/README.md
  52. 106
      subjects/what-is-my-purpose/README.md
  53. 20
      subjects/wololo/README.md
  54. 7
      subjects/words/README.md
  55. 61
      subjects/you-pass-butter/README.md
  56. 21
      subjects/you-spin-me-round/README.md

26
js/tests/a-new-purpose.json

@ -0,0 +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, 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 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": "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": "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)"
}
]

26
js/tests/a-winning-argument.json

@ -0,0 +1,26 @@
[
{
"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": "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": "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}"
},
{
"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}"
},
{
"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}"
},
{
"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}"
}
]

22
js/tests/give-it-a-rest.json

@ -0,0 +1,22 @@
[
{
"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": "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": "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": "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": "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)"
}
]

26
js/tests/happy.json

@ -0,0 +1,26 @@
[
{
"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}"
},
{
"description": "happy has 1 argument",
"code": "if (happy.length != 1) {\n throw Error('You need 1 argument for this function!')\n}"
},
{
"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": "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}"
},
{
"description": "happy has no keyword return.",
"code": "if (happy.toString().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}"
}
]

14
js/tests/level-up.json

@ -0,0 +1,14 @@
[
{
"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 has 3 arguments",
"code": "if (shaker.length != 3) {\n throw Error('You need 3 arguments for this function!')\n}"
},
{
"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')"
}
]

22
js/tests/my-house.json

@ -0,0 +1,22 @@
[
{
"description": "acidHouse and deepHouse are objects",
"code": "let mainHouse = { door: 'blue', rooms: { bedrooms: 2, bathrooms: 1 } }\n\n// Your code\n\nequal(typeof acidHouse, 'object')\nequal(typeof deepHouse, 'object')"
},
{
"description": "acidHouse is not a reference",
"code": "let mainHouse = { door: 'blue', rooms: { bedrooms: 2, bathrooms: 1 } }\n\n// Your code\n\nmainHouse.door = 'red'\n\nif (acidHouse.door === 'red') {\n throw Error(\n 'when painting mainHouse.door in red, acidHouse.door is painted red too. You did not do a shallow copy',\n )\n}"
},
{
"description": "acidHouse is not a deep copy",
"code": "let mainHouse = { door: 'blue', rooms: { bedrooms: 2, bathrooms: 1 } }\n\n// Your code\n\nmainHouse.rooms.bathrooms = 3\n\nif (acidHouse.rooms.bathrooms !== 3) {\n throw Error(\n 'when adding 2 bathrooms to mainHouse, acidHouse did not get 2 extra bathrooms as well, it looks like you did a deep copy instead of a shallow one...',\n )\n}"
},
{
"description": "deepHouse is not a reference",
"code": "let mainHouse = { door: 'blue', rooms: { bedrooms: 2, bathrooms: 1 } }\n\n// Your code\n\nmainHouse.door = 'red'\n\nif (deepHouse.door === 'red') {\n throw Error(\n 'when painting mainHouse.door in red, deepHouse.door is painted red too, you did not do a deep copy',\n )\n}"
},
{
"description": "deepHouse is not a shallow copy",
"code": "let mainHouse = { door: 'blue', rooms: { bedrooms: 2, bathrooms: 1 } }\n\n// Your code\n\nmainHouse.rooms.bathrooms = 3\n\nif (deepHouse.rooms.bathrooms !== 1) {\n throw Error(\n 'when adding 2 bathrooms to mainHouse, deepHouse didgot extra bathrooms as well, it looks like you did a shallow copy instead of a deep copy...',\n )\n}"
}
]

4
js/tests/parenting.json

@ -10,5 +10,9 @@
{
"description": "child.parent must be equal to parent",
"code": "equal(child.parent, parent)"
},
{
"description": "child.parent.child must be equal to itself",
"code": "equal(child.parent.child, child)"
}
]

22
js/tests/phant0m-writ3r.json

@ -0,0 +1,22 @@
[
{
"description": "Tests with 'fermentation'",
"code": "let word = 'fermentation'\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['fermentation'])"
},
{
"description": "Tests with 'bathrobe'",
"code": "let word = 'bathrobe'\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args, [])"
},
{
"description": "Tests with 'alimentation'",
"code": "let word = 'alimentation'\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args, [])"
},
{
"description": "Tests with 'alibaba'",
"code": "let word = 'alibaba'\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args, [])"
},
{
"description": "Tests with 'caution'",
"code": "let word = 'caution'\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['caution'])"
}
]

46
js/tests/rest-in-peace.json

@ -0,0 +1,46 @@
[
{
"description": "footSoldiers, horseMen, and armyOfTheDead are each an array",
"code": "let swordMen = []\nlet archers = []\nlet captains = []\nlet generals = []\n\n// Your code\n\nif (!Array.isArray(footSoldiers)) {\n throw Error('footSoldiers is not an Array')\n}\nif (!Array.isArray(horseMen)) {\n throw Error('horseMen is not an Array')\n}\nif (!Array.isArray(armyOfTheDead)) {\n throw Error('armyOfTheDead is not an Array')\n}"
},
{
"description": "push is not used",
"code": "let swordMen = []\nlet archers = []\nlet captains = []\nlet generals = []\nconst pushCalls = saveArguments(Array.prototype, 'push')\n\n// Your code\n\nequal(pushCalls.length, 0) // push should not be used"
},
{
"description": "unshift is not used",
"code": "let swordMen = []\nlet archers = []\nlet captains = []\nlet generals = []\nconst unshiftCalls = saveArguments(Array.prototype, 'unshift')\n\n// Your code\n\nequal(unshiftCalls.length, 0) // unshift should not be used"
},
{
"description": "concat is not used",
"code": "let swordMen = []\nlet archers = []\nlet captains = []\nlet generals = []\nconst concatCalls = saveArguments(Array.prototype, 'concat')\n\n// Your code\n\nequal(concatCalls.length, 0) // concat should not be used"
},
{
"description": "footSoldiers has 9 soldiers (including their leader)",
"code": "let swordMen = [\n 'Jack Churchill',\n 'Sasaki Kojiro',\n 'Johannes Liechtenauer',\n 'Fiore dei Liberi',\n]\nlet archers = ['William Tell', 'Artemis', 'Fred Bear', 'Nasu no Yoichi']\nlet captains = ['Guts', 'Edward the Black Prince', 'Joan of Arc']\nlet generals = ['Napoleon', 'Emilia Plater']\n\n// Your code\n\nequal(footSoldiers.length, 9)"
},
{
"description": "Grim the Terrible is behind his footSoldiers",
"code": "let swordMen = [\n 'Jack Churchill',\n 'Sasaki Kojiro',\n 'Johannes Liechtenauer',\n 'Fiore dei Liberi',\n]\nlet archers = ['William Tell', 'Artemis', 'Fred Bear', 'Nasu no Yoichi']\nlet captains = ['Guts', 'Edward the Black Prince', 'Joan of Arc']\nlet generals = ['Napoleon', 'Emilia Plater']\n\n// Your code\n\nequal(footSoldiers, [\n 'Jack Churchill',\n 'Sasaki Kojiro',\n 'Johannes Liechtenauer',\n 'Fiore dei Liberi',\n 'William Tell',\n 'Artemis',\n 'Fred Bear',\n 'Nasu no Yoichi',\n 'Grim the Terrible',\n])"
},
{
"description": "horseMen has 6 knights (including their leader)",
"code": "let swordMen = [\n 'Jack Churchill',\n 'Sasaki Kojiro',\n 'Johannes Liechtenauer',\n 'Fiore dei Liberi',\n]\nlet archers = ['William Tell', 'Artemis', 'Fred Bear', 'Nasu no Yoichi']\nlet captains = ['Guts', 'Edward the Black Prince', 'Joan of Arc']\nlet generals = ['Napoleon', 'Emilia Plater']\n\n// Your code\n\nequal(horseMen.length, 6)"
},
{
"description": "The Skull Knight is in front of his horseMen",
"code": "let swordMen = [\n 'Jack Churchill',\n 'Sasaki Kojiro',\n 'Johannes Liechtenauer',\n 'Fiore dei Liberi',\n]\nlet archers = ['William Tell', 'Artemis', 'Fred Bear', 'Nasu no Yoichi']\nlet captains = ['Guts', 'Edward the Black Prince', 'Joan of Arc']\nlet generals = ['Napoleon', 'Emilia Plater']\n\n// Your code\n\nequal(horseMen, [\n 'The Skull Knight',\n 'Guts',\n 'Edward the Black Prince',\n 'Joan of Arc',\n 'Napoleon',\n 'Emilia Plater',\n])"
},
{
"description": "armyOfTheDead is 16 soldiers strong",
"code": "let swordMen = [\n 'Jack Churchill',\n 'Sasaki Kojiro',\n 'Johannes Liechtenauer',\n 'Fiore dei Liberi',\n]\nlet archers = ['William Tell', 'Artemis', 'Fred Bear', 'Nasu no Yoichi']\nlet captains = ['Guts', 'Edward the Black Prince', 'Joan of Arc']\nlet generals = ['Napoleon', 'Emilia Plater']\n\n// Your code\n\nequal(armyOfTheDead.length, 16)"
},
{
"description": "The King of the Dead is in between footSoldiers and horseMen",
"code": "let swordMen = [\n 'Jack Churchill',\n 'Sasaki Kojiro',\n 'Johannes Liechtenauer',\n 'Fiore dei Liberi',\n]\nlet archers = ['William Tell', 'Artemis', 'Fred Bear', 'Nasu no Yoichi']\nlet captains = ['Guts', 'Edward the Black Prince', 'Joan of Arc']\nlet generals = ['Napoleon', 'Emilia Plater']\n\n// Your code\n\nequal(armyOfTheDead, [\n 'Jack Churchill',\n 'Sasaki Kojiro',\n 'Johannes Liechtenauer',\n 'Fiore dei Liberi',\n 'William Tell',\n 'Artemis',\n 'Fred Bear',\n 'Nasu no Yoichi',\n 'Grim the Terrible',\n 'The King of the Dead',\n 'The Skull Knight',\n 'Guts',\n 'Edward the Black Prince',\n 'Joan of Arc',\n 'Napoleon',\n 'Emilia Plater',\n])"
},
{
"description": "The army of the dead is still ordered if the soldiers are different",
"code": "let swordMen = [\n 'Zorro',\n 'Sasaki Kojiro',\n 'Johannes Liechtenauer',\n 'Fiore dei Liberi',\n]\nlet archers = [\n 'William Tell',\n 'Artemis',\n 'Fred Bear',\n 'Nasu no Yoichi',\n 'Rambo',\n]\nlet captains = ['Price', 'Guts', 'Edward the Black Prince', 'Joan of Arc']\nlet generals = ['Queen Elizabeth II', 'Emilia Plater']\n\n// Your code\n\nequal(armyOfTheDead, [\n 'Zorro',\n 'Sasaki Kojiro',\n 'Johannes Liechtenauer',\n 'Fiore dei Liberi',\n 'William Tell',\n 'Artemis',\n 'Fred Bear',\n 'Nasu no Yoichi',\n 'Rambo',\n 'Grim the Terrible',\n 'The King of the Dead',\n 'The Skull Knight',\n 'Price',\n 'Guts',\n 'Edward the Black Prince',\n 'Joan of Arc',\n 'Queen Elizabeth II',\n 'Emilia Plater',\n])"
}
]

22
js/tests/security.json

@ -0,0 +1,22 @@
[
{
"description": "Test a traveler that is still has the virus",
"code": "let traveler = {\n alreadyHadTheVirus: true,\n recovered: false,\n isVaccinated: false,\n}\n\n// Your code\n\nequal(traveler.isImmune, false)"
},
{
"description": "Test a traveler that has recovered",
"code": "let traveler = {\n alreadyHadTheVirus: true,\n recovered: true,\n isVaccinated: false,\n}\n\n// Your code\n\nequal(traveler.isImmune, true)"
},
{
"description": "Test a traveler who never had the virus and isn't vaccinated",
"code": "let traveler = {\n alreadyHadTheVirus: false,\n recovered: false,\n isVaccinated: false,\n}\n\n// Your code\n\nequal(traveler.isImmune, false)"
},
{
"description": "Test a traveler that is vaccinated",
"code": "let traveler = {\n alreadyHadTheVirus: false,\n recovered: false,\n isVaccinated: true,\n}\n\n// Your code\n\nequal(traveler.isImmune, true)"
},
{
"description": "Test a traveler that is vaccinated and recovered from the virus",
"code": "let traveler = { alreadyHadTheVirus: true, recovered: true, isVaccinated: true }\n\n// Your code\n\nequal(traveler.isImmune, true)"
}
]

46
js/tests/seeker-of-truth.json

@ -0,0 +1,46 @@
[
{
"description": "Test with the falsy value 0",
"code": "const args = saveArguments(console, 'log')\nlet truth = 0\n\n// Your code\n\nequal(args[0]?.[0], 'Lies !!!!')"
},
{
"description": "Test with the falsy value NaN",
"code": "const args = saveArguments(console, 'log')\nlet truth = NaN\n\n// Your code\n\nequal(args[0]?.[0], 'Lies !!!!')"
},
{
"description": "Test with the falsy value undefined",
"code": "const args = saveArguments(console, 'log')\nlet truth = undefined\n\n// Your code\n\nequal(args[0]?.[0], 'Lies !!!!')"
},
{
"description": "Test with the falsy value null",
"code": "const args = saveArguments(console, 'log')\nlet truth = null\n\n// Your code\n\nequal(args[0]?.[0], 'Lies !!!!')"
},
{
"description": "Test with the falsy value ''",
"code": "const args = saveArguments(console, 'log')\nlet truth = ''\n\n// Your code\n\nequal(args[0]?.[0], 'Lies !!!!')"
},
{
"description": "Test with the falsy value false",
"code": "const args = saveArguments(console, 'log')\nlet truth = false\n\n// Your code\n\nequal(args[0]?.[0], 'Lies !!!!')"
},
{
"description": "Test with the truthy value 'Sure'",
"code": "const args = saveArguments(console, 'log')\nlet truth = 'Sure'\n\n// Your code\n\nequal(args[0]?.[0], 'The truth was spoken.')"
},
{
"description": "Test with the truthy value []",
"code": "const args = saveArguments(console, 'log')\nlet truth = []\n\n// Your code\n\nequal(args[0]?.[0], 'The truth was spoken.')"
},
{
"description": "Test with the truthy value {}",
"code": "const args = saveArguments(console, 'log')\nlet truth = {}\n\n// Your code\n\nequal(args[0]?.[0], 'The truth was spoken.')"
},
{
"description": "Test with the truthy value true",
"code": "const args = saveArguments(console, 'log')\nlet truth = true\n\n// Your code\n\nequal(args[0]?.[0], 'The truth was spoken.')"
},
{
"description": "Test with the truthy value -0.1",
"code": "const args = saveArguments(console, 'log')\nlet truth = -0.1\n\n// Your code\n\nequal(args[0]?.[0], 'The truth was spoken.')"
}
]

22
js/tests/special-promo.json

@ -0,0 +1,22 @@
[
{
"description": "Test with a user that can have the promotion",
"code": "const args = saveArguments(console, 'log')\nlet user = { activeMembership: true, age: 22 }\n\n// Your code\n\nequal(args[0]?.[0], 'You can benefit from our special promotion')"
},
{
"description": "Test with a user that is too old",
"code": "const args = saveArguments(console, 'log')\nlet user = { activeMembership: true, age: 33 }\n\n// Your code\n\nequal(args[0]?.[0], undefined)"
},
{
"description": "Test with a user that is too young",
"code": "const args = saveArguments(console, 'log')\nlet user = { activeMembership: true, age: 12 }\n\n// Your code\n\nequal(args[0]?.[0], undefined)"
},
{
"description": "Test with a user that doesn't have an active membership",
"code": "const args = saveArguments(console, 'log')\nlet user = { activeMembership: false, age: 21 }\n\n// Your code\n\nequal(args[0]?.[0], undefined)"
},
{
"description": "Test with a user that can have the promotion but is just at the limit",
"code": "const args = saveArguments(console, 'log')\nlet user = { activeMembership: true, age: 25 }\n\n// Your code\n\nequal(args[0]?.[0], 'You can benefit from our special promotion')"
}
]

30
js/tests/spread-the-word.json

@ -0,0 +1,30 @@
[
{
"description": "beaconsLit is an Array",
"code": "const easternmost = 'Amon Dîn'\nlet easternBeacons = ['Eilenach', 'Nardol']\nconst centerBeacon = 'Erelas'\nlet westernBeacons = ['Min-Rimmon', 'Calenhad']\nconst westernmost = 'Amon Anwar'\n\n// Your code\n\nif (!Array.isArray(beaconsLit)) {\n throw Error('beaconsLit is not an Array')\n}"
},
{
"description": "beaconsLit is created without using push",
"code": "const easternmost = 'Amon Dîn'\nlet easternBeacons = ['Eilenach', 'Nardol']\nconst centerBeacon = 'Erelas'\nlet westernBeacons = ['Min-Rimmon', 'Calenhad']\nconst westernmost = 'Amon Anwar'\nconst pushCalls = saveArguments(Array.prototype, 'push')\n\n// Your code\n\nequal(pushCalls.length, 0) // push should not be used"
},
{
"description": "beaconsLit is created without using unshift",
"code": "const easternmost = 'Amon Dîn'\nlet easternBeacons = ['Eilenach', 'Nardol']\nconst centerBeacon = 'Erelas'\nlet westernBeacons = ['Min-Rimmon', 'Calenhad']\nconst westernmost = 'Amon Anwar'\nconst unshiftCalls = saveArguments(Array.prototype, 'unshift')\n\n// Your code\n\nequal(unshiftCalls.length, 0) // unshift should not be used"
},
{
"description": "beaconsLit is created without using concat",
"code": "const easternmost = 'Amon Dîn'\nlet easternBeacons = ['Eilenach', 'Nardol']\nconst centerBeacon = 'Erelas'\nlet westernBeacons = ['Min-Rimmon', 'Calenhad']\nconst westernmost = 'Amon Anwar'\nconst concatCalls = saveArguments(Array.prototype, 'concat')\n\n// Your code\n\nequal(concatCalls.length, 0) // concat should not be used"
},
{
"description": "beaconsLit has the 7 beacons lit",
"code": "const easternmost = 'Amon Dîn'\nlet easternBeacons = ['Eilenach', 'Nardol']\nconst centerBeacon = 'Erelas'\nlet westernBeacons = ['Min-Rimmon', 'Calenhad']\nconst westernmost = 'Amon Anwar'\n\n// Your code\n\nequal(beaconsLit.length, 7)"
},
{
"description": "beaconsLit has the right beacons",
"code": "const easternmost = 'Amon Dîn'\nlet easternBeacons = ['Eilenach', 'Nardol']\nconst centerBeacon = 'Erelas'\nlet westernBeacons = ['Min-Rimmon', 'Calenhad']\nconst westernmost = 'Amon Anwar'\n\n// Your code\n\nequal(beaconsLit, [\n 'Amon Dîn',\n 'Eilenach',\n 'Nardol',\n 'Erelas',\n 'Min-Rimmon',\n 'Calenhad',\n 'Amon Anwar',\n])"
},
{
"description": "beaconsLit should still work if the values are different",
"code": "const easternmost = 'Amon Din'\nlet easternBeacons = ['Eilenach']\nconst centerBeacon = 'नरडल'\nlet westernBeacons = ['Erelas', 'Min-Rimmon', 'Calenhad']\nconst westernmost = 'Amon Anwar (Halifirien)'\n\n// Your code\n\nequal(beaconsLit, [\n 'Amon Din',\n 'Eilenach',\n 'नरडल',\n 'Erelas',\n 'Min-Rimmon',\n 'Calenhad',\n 'Amon Anwar (Halifirien)',\n])"
}
]

18
js/tests/time-to-pay.json

@ -0,0 +1,18 @@
[
{
"description": "Test with a customer that has enough cash",
"code": "let ticketSold = 8\nlet customer = { cash: 20, hasVoucher: false }\n\n// Your code\n\nequal(ticketSold, 9)"
},
{
"description": "Test with a customer that has a voucher",
"code": "let ticketSold = 5\nlet customer = { cash: 0, hasVoucher: true }\n\n// Your code\n\nequal(ticketSold, 6)"
},
{
"description": "Test with a customer that has a voucher and cash",
"code": "let ticketSold = 6\nlet customer = { cash: 42, hasVoucher: true }\n\n// Your code\n\nequal(ticketSold, 7)"
},
{
"description": "Test with a customer that can not afford the ticket",
"code": "let ticketSold = 3\nlet customer = { cash: 3, hasVoucher: false }\n\n// Your code\n\nequal(ticketSold, 3)"
}
]

6
js/tests/to-infinity-and-beyond.json

@ -0,0 +1,6 @@
[
{
"description": "Not implemented",
"code": "throw Error('oops')"
}
]

26
js/tests/two-can-play-that-game.json

@ -0,0 +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 has two arguments",
"code": "if (duos.length != 2) {\n throw Error('You need two arguments for this function!')\n}"
},
{
"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": "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 has three arguments",
"code": "if (duosWork.length != 3) {\n throw Error('You need three arguments for this function!')\n}"
},
{
"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}"
}
]

18
js/tests/virus19.json

@ -0,0 +1,18 @@
[
{
"description": "Freeze the virus19",
"code": "const antivirus = { C8H10N4O: true, C12H22O11: true }\nconst virus19 = {\n dangerosity: 'extremely dangerous',\n contagiousness: 'contagious',\n}\n\n// Your code\n\nif (!Object.isFrozen(virus19)) {\n throw Error('you did not freeze the virus19 properly. It can mutate!')\n}"
},
{
"description": "vaccine is an object",
"code": "const antivirus = { C8H10N4O: true, C12H22O11: true }\nconst virus19 = {\n dangerosity: 'extremely dangerous',\n contagiousness: 'contagious',\n}\n\n// Your code\n\nequal(typeof vaccine, 'object')"
},
{
"description": "vaccine contains the right molecules",
"code": "const antivirus = { C8H10N4O: true, C12H22O11: true }\nconst virus19 = {\n dangerosity: 'extremely dangerous',\n contagiousness: 'contagious',\n}\n\n// Your code\n\nequal(vaccine, antivirus)"
},
{
"description": "vaccine is frozen",
"code": "const antivirus = { C8H10N4O: true, C12H22O11: true }\nconst virus19 = {\n dangerosity: 'extremely dangerous',\n contagiousness: 'contagious',\n}\n\n// Your code\n\nif (!Object.isFrozen(vaccine)) {\n throw Error('you did not secure your vaccine components')\n}"
}
]

18
js/tests/what-else.json

@ -0,0 +1,18 @@
[
{
"description": "Test with an empty list",
"code": "let vips = []\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['The only failure is not to try.'])"
},
{
"description": "Test if he is not invited",
"code": "let vips = ['Dora', 'Bruce Willis']\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['The only failure is not to try.'])"
},
{
"description": "Test if he is in the list",
"code": "let vips = ['Dora', 'Jacky', 'George Clooney', 'Bruce Willis']\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['What else ?'])"
},
{
"description": "Test if he is the first in the list",
"code": "let vips = ['George Clooney', 'Jacky', 'Bruce Willis']\nconst args = saveArguments(console, 'log')\n\n// Your code\n\nequal(args[0], ['What else ?'])"
}
]

26
js/tests/what-is-my-purpose.json

@ -0,0 +1,26 @@
[
{
"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": "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": "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": "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": "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}"
}
]

14
js/tests/you-pass-butter.json

@ -0,0 +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 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": "// Your code\n\nlet theTable = passButter()\n\nif (theTable != 'The butter') {\n throw Error(`passButter() did not return 'The butter'`)\n}"
}
]

53
subjects/a-new-purpose/README.md

@ -0,0 +1,53 @@
## A new purpose
### Treating data in and out
You know now how to declare the `arguments` and the `return` values of a
function. You know have the tools to:
- receive data in the function (in the form of the arguments)
- treat the data (in the fonction scope)
- return the treated data (with the return keyword)
You can now for example, transform this function which we used right before:
```js
let myFirstFunction = (continent, country, city, temperature) => {
console.log(continent, country, city, temperature)
} //<- end of the scope of the function
// Now we call the function
myFirstFunction('Europe', 'France', 'Paris', '30°C')
// 'Europe'
// 'France'
// 'Paris'
// '30°C'
```
into:
```js
let myFirstFunction = (continent, country, city, temperature) => {
//<as many arguments as needed
return `${city} is a city in ${country} in the continent ${continent} where the temperature is of ${temperature} today.`
} //<-end of the scope of the function
// arg arg arg arg
// Now we call the function ↘ in, in, in, in,
let resultOfMyfunction = myFirstFunction('Europe', 'France', 'Paris', '30°C')
// ↖ and out
console.log(resultOfMyFunction) // below, is the log of what the function returned to us.
// 'Paris is a city in France in the continent Europe where the temperature is of 30°C today.'
```
### Instructions
As Rick's robot, you want to do something more than just pass the butter. You
want to level up so you decide to take your destiny into your own pliers. You
are going to start slow by competing with calculators.
Define the functions :
- `add2` which adds two arguments and returns the result.
- `sub2` which substract two arguments and returns the result.
- `mult2` which substract two arguments and returns the result.
- `div2` which divides two arguments and returns the result.

71
subjects/a-winning-argument/README.md

@ -0,0 +1,71 @@
## A winning argument
### Arguments
We mentioned it before with methods, functions can take arguments. They are
always in between parens `()`.
Let's use the same examples that we used for function calls:
Remember this example of function call?:
```js
// ↙ method
console.log('Hello There !') //<-
// ↖ The String 'Hello There!' is
// the argument of console.log()
```
or these ones?:
```js
let roundedValue = Math.round(1.8) // The number 1.8 is the arg
console.log(roundedValue) // the variable roundedValue is the arg
```
We are now going to adapt `myFirstFuntion` so that it takes one argument :
`arg1`.
```js
let myFirstFunction = (arg1) => {
//<-arg1 is inputed in between the parens
console.log(arg1) // arg1 can be use inside the scope of the function
// ↖ arg1 is "transfered" to be the arg of console.log()
} //<-end of the scope of the function
```
Now the function if called, display the output the `console.log(arg1)`.
```js
myFirstFunction('using my first arg') // "using my first arg"
```
But let's say we want to change what the function logs. Now, instead of
modifying `myFirstFunction` we just need to modify the argument in the function
call.
```js
myFirstFunction('another arg') // "another arg"
myFirstFunction('and another one') // "and another one"
myFirstFunction('and one more') // "and one more"
```
> waste no more time arguing about what a good man should be. Be one.
>
> - Marcus Aurelius
### Instructions
You are a general's aide who has to transmit the communications to the other
soldiers.
In order to do so you will create the function `battleCry`. This function will
take one argument and will display it in the console.
The battlefield is big so make sure that the argument is uppercased before
displaying it.
Now, sometimes the communications will have to given quietly.
For this you will create the function `secretOrders` which does the same as
`battleCry` except that it lowercases the argument before sending it.

2
subjects/access/README.md

@ -1,4 +1,4 @@
## Access
## Access 🔑
Now that we know how to define objects, let's start to use them

10
subjects/all-caps/README.md

@ -19,9 +19,9 @@ console.log(thirdOf10.toFixed(3)) // -> '3.333' that's quite enough !
console.log(thirdOf10.toFixed()) // -> with no argument, we get just '3'
```
So here in that second to last line we call `toFixed` from the value of the variable
`thirdOf10`, with the argument `3`, saying that we want 3 decimal numbers in our
string conversion.
So here in that second to last line we call `toFixed` from the value of the
variable `thirdOf10`, with the argument `3`, saying that we want 3 decimal
numbers in our string conversion.
Since they are functions, they can also return values.
@ -30,8 +30,8 @@ Since they are functions, they can also return values.
One of the value with the most methods are strings, you can do a lot of things
with them.
For this exercise you will have to use the methods `toUpperCase` and `toLowerCase` from the
provided variable `message`.
For this exercise you will have to use the methods `toUpperCase` and
`toLowerCase` from the provided variable `message`.
- Create a `noCaps` variable of the value of `message` but in lower case.
- Create an `allCaps` variable of the value of `message` but in upper case.

2
subjects/alter-ego/README.md

@ -1,4 +1,4 @@
## Alter Ego
## Alter Ego 🎭
You can change your objects in multiple ways:

2
subjects/anything-to-declare/README.md

@ -1,4 +1,4 @@
## Anything to Declare ?
## Anything to Declare ? 🛂
### Variables

6
subjects/cut/README.md

@ -1,9 +1,9 @@
## Cut
## Cut
### Instructions
Using the `.slice` method and the provided `alphabet` variable which is a string of all
the character in an alphabet:
Using the `.slice` method and the provided `alphabet` variable which is a string
of all the character in an alphabet:
- Declare a `cutFirst` variable that removes the 10 first characters of
`alphabet`.

23
subjects/give-it-a-rest/README.md

@ -0,0 +1,23 @@
## 🌟 Give it a ...rest
### Notions
- [devdocs.io/functions/rest_parameters](https://devdocs.io/javascript/functions/rest_parameters)
- [devdocs.io/javascript/global_objects/array/reduce](https://devdocs.io/javascript/global_objects/array/reduce)
### Instructions
You are now a butter passer, calculator, and barttender all-in-one robot. You
want to keep on improving but you can feel like your memory capacities are
reaching their limits. You will now try to improve what you aready have.
Declare the function `addAll` which will will return the sum of all the
arguments it recieves. Examples:
```js
console.log(addAll(1)) //1
console.log(addAll(1, 10)) //11
console.log(addAll(1, 10, 100)) //111
```
You will then do exactly the same for `subAll`, `MultAll` and `divAll`.

22
subjects/griswold-the-blacksmith/README.md

@ -1,4 +1,4 @@
## Griswold the Blacksmith
## Griswold the Blacksmith
Methods and built-in functions are good, but most of the time we have to write
our own logic and the first block for that are **conditions**.
@ -35,8 +35,8 @@ There are 6 different comparaison opperators:
- `!==` _not equal to_
Every comparaison operator are _like_ functions, they take 2 arguments, one on
the right and one on the left, and returns a boolean value. Either `true`, if the
condition is met, or `false` if it's not.
the right and one on the left, and returns a boolean value. Either `true`, if
the condition is met, or `false` if it's not.
Since they return value, you can assign them to variables, just like functions
return values:
@ -60,7 +60,8 @@ Scopes are a way to group lines of code, this allow us to do multiple lines of
code if a condition is true.
```js
if (age > 48) { // <-beginning of the scope of the if condition
if (age > 48) {
// <-beginning of the scope of the if condition
console.log('You are over 48 years old')
} // <- end of the scope of the if condition
```
@ -69,8 +70,8 @@ if (age > 48) { // <-beginning of the scope of the if condition
Upon writing code inside a scope, it's an important convention to **indent** it.
Indenting is when spaces are added at the beginning of the line, here is an example of
bad code:
Indenting is when spaces are added at the beginning of the line, here is an
example of bad code:
<!-- prettier-ignore-start -->
```js
@ -96,8 +97,8 @@ the code clear.
### Instructions
You are Griswold the Blacksmith, and you must give the list of items the
player can buy with the money he has, here is what you are selling:
You are Griswold the Blacksmith, and you must give the list of items the player
can buy with the money he has, here is what you are selling:
- arrows for 3 coins
- boots for 44 coins
@ -106,8 +107,7 @@ player can buy with the money he has, here is what you are selling:
Declare a `purchasableGoods` array and _conditionally_ push to it all the goods
that the player can buy.
Use `if` conditions and compare the cost of the goods with the provided
variable `playerCoins` that contains the number of coins available to
the player.
Use `if` conditions and compare the cost of the goods with the provided variable
`playerCoins` that contains the number of coins available to the player.
> You must order elements by price

31
subjects/happy/README.md

@ -0,0 +1,31 @@
## 🌟 Happy?
### Notions
[devdocs.io/javascript/global_objects/string/includes](https://devdocs.io/javascript/global_objects/string/includes)
[developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator)
### Instructions
With all the you know now you are not a truly happy, efficient and independent
robot.
You have decided that if someone ask you the question `Are you happy?` or
questions that includes the word `happy` you will always says that it is `true`.
To do so you will declare the function `happy` which takes only one argument and
returns a boolean.
Examples:
```js
console.log(happy('Are you happy?')) // true
console.log(happy('Happy?')) // true
console.log(happy('Are you happy!')) // false -> this is not a question
console.log(happy('Are you sad?')) // false -> wrong question
```
Any other requests will be denied with a `false`. (if it is not a question of if
it does not have the word `happy`).
And because you aim for efficiency you will contruct your fonction without the
curlys brackets `{}` and without the keyword `return` or `if`.

4
subjects/keep/README.md

@ -2,8 +2,8 @@
### Instructions
Using the `.slice` method again and the provided `alphabet` variable of a string of
all the characters in an alphabet:
Using the `.slice` method again and the provided `alphabet` variable of a string
of all the characters in an alphabet:
- Declare a `keepFirst` variable of only the 6 first characters from `alphabet`.
- Declare a `keepLast` variable of only the 7 last characters from `alphabet`.

52
subjects/level-up/README.md

@ -0,0 +1,52 @@
## level up
You know now, in your function declarations, how to use arguments and returns.
Let's try to now use the `if` statements in a new function called `happy`. Here
is an example:
```js
let happy = (mood) => {
if (mood === 'happy') {
return true
}
return false
}
let result1 = happy('happy')
let result2 = happy('sad')
console.log(result1) //true
console.log(result2) //false
```
Here we used the `if` statement, and two `return` keywords to alternate between
the result `true` or `false` depending whether the argument `mood` is equal to
the string `happy` or not. The possibilities are becoming limitless...
### Instructions
As Rick's robot, you are continuing your training to add yourself new ... skills
(I could have said funtions). You want now to become a robot bartender.
Define the function `shaker` which will take as arguments:
- `quantity`, which will be variable of type `Number`
- `fruit`, which will be a `String`
- `alcohol`, which will be a `Boolean`
`shaker` must return a `String`. Look at the examples below to understand how
`shaker` must mix its ingredients:
```js
console.log(shaker(1, 'strawberry', true))
//'1 strawberry cocktail'
console.log(shaker(2, 'chocolate', false))
//'2 chocolate milkshakes'
console.log(shaker(2, 'strawberry', true))
//'2 strawberry cocktails'
console.log(shaker(1, 'chocolate', false))
//'1 chocolate milkshake'
```
Ps: watch out for your plurals!

11
subjects/maximus/README.md

@ -1,4 +1,4 @@
## Maximus
## Maximus
![maximus](https://user-images.githubusercontent.com/231748/112197288-d322dd00-8c03-11eb-95e4-a5253043578d.jpg)
@ -17,7 +17,8 @@ Values are simply separated by a `,` comma, like values in an Array.
We provide you with 3 users objects assigned in their respective variables
`martin`, `kevin`, and `stephanie`.
- Declare an `oldestAge` variable that use the `Math.max` on their `age` property
to find the oldest age.
Hint: Maybe find out how the Math.max function works before starting this exercise.
- Declare an `oldestAge` variable that use the `Math.max` on their `age`
property to find the oldest age.
Hint: Maybe find out how the Math.max function works before starting this
exercise.

64
subjects/my-house/README.md

@ -0,0 +1,64 @@
## 🌟 My House 🏠
One should be aware that copying an objet in Js is not a straightfoward process.
Let's try with an object `mainHouse`. Given what we know, the first instinct
would be to do something like this:
```js
let mainHouse = {
door: 'blue',
rooms: {
bedrooms: 2,
bathrooms: 1,
},
}
let sameHouse = mainHouse
```
If we `console.log` both `mainHouse` and `sameHouse` we will obtain exactly the
same output:
```js
console.log(mainHouse) // { door: 'blue', rooms: 3 }
console.log(sameHouse) // { door: 'blue', rooms: 3 }
```
So far, so good. Now, let's get into the issue. Let's paint the door of
`mainHouse` in `red`.
```js
mainHouse.door = 'red'
```
If we `console.log` both `mainHouse` and `sameHouse` we will now obtain:
```js
console.log(mainHouse) // { door: 'red', rooms: 3}
console.log(sameHouse) // { door: 'red', rooms: 3}
```
But wait a second... we just wanted to paint the door of `mainHouse`. What
happened here? Why are both doors painted in red?
Well, unlike primitives that can not changes, _(the number `1` will always be
the number `1`)_ objects can mutate.
You can add, delete and update properties, so if two different variables are
assigned to the same object value, they will both mutate the same object.
We call that a reference, not a copy.
There are multiple ways to copies objects. Understanding the limitations of each
of these ways is very important. Which is why this time, you will have to do a
bit of research...
### Instructions
We will declare the same `mainHouse` seen in the lesson above.
- Declare `acidHouse` which will be a `shallow copy` of `mainHouse`.
- Declare `deepHouse` which will be a `deep copy` of `mainHouse`.
> Not in my house! \
> ― Dikembe Mutombo

2
subjects/notorious/README.md

@ -1,4 +1,4 @@
## 🌟 Notorious
## 🌟 Notorious 🎤
### Notions

2
subjects/parenting/README.md

@ -1,4 +1,4 @@
## 🌟 Parenting
## 🌟 Parenting 👨👧
You are now beginning **BONUS** exercises, those are made to make you explore JS
a bit more by yourself and show you more obscure / weird aspects of the

27
subjects/phant0m-writ3r/README.md

@ -0,0 +1,27 @@
## PHANT0M-WRiT3R 👻
### Using functions in conditions
Any expressions is valid code inside conditions, that includes functions calls:
```js
// for example, we can uppercase to make sure it will match
// no mater if the name has upper or lower letter !
if ('Patrick Lemaire'.toUpperCase() === 'PATRICK LEMAIRE') {
console.log('This is Patrick')
}
```
### Instructions
Your carreer as a rap ghost writer is at a dead end as inspiration seems to have
left for good, but you still have an ace up your sleeve, you will write a bot
`PHANT0M-WRiT3R` that find ryhmes for you !
- Log the provided variable `word` if it does not start with `'al'` and end with
`'ion'`
### Notions
- [startsWith](https://devdocs.io/javascript/global_objects/string/startsWith)
- [endsWith](https://devdocs.io/javascript/global_objects/string/endsWith)

2
subjects/pop-art/README.md

@ -1,4 +1,4 @@
## Pop Art
## Pop Art 🎨
### Instructions

2
subjects/ratchet-clap/README.md

@ -1,4 +1,4 @@
## Ratchet Clap
## Ratchet👏Clap👏
Let's do the opposite !

2
subjects/redeclaration-of-love/README.md

@ -1,4 +1,4 @@
## Redeclaration of Love
## Redeclaration of Love 💕
### Assign, re-assign

42
subjects/rest-in-peace/README.md

@ -0,0 +1,42 @@
## 🌟 Rest in peace
### Notions
- [devdocs.io/operators/spread_syntax](https://devdocs.io/javascript/operators/spread_syntax)
### Instructions
The battle is won! The Army of the Dead have finally fulfilled their oath. It is
now time to free them so that they may rest in peace.
But first we need to regroup and count them to make sure not one single soul is
left behind. We will provide a four variables of type array:
- `swordMen`
- `archers`
- `captains`
- `generals`
You will need to concat the content of `swordMen` and `archers` into one array
`footSoldiers`. That batallion is lead by `'Grim the Terrible'`. He likes to
scream to soldiers that walks too slow, so you need to put him as the last
element of the array.
Then you will do the same for `captains` and `generals` into the array
`horseMen`. That batallion is lead by `'The Skull Knight'`. He, on the other
hand, likes to lead from the front. He needs to be the first element of the
array.
Finally you will do it one more time for `footSoldiers` and `horseMen` into the
array `armyOfTheDead`. For having a better overview, `'The King of the Dead'`
needs to be tactically positioned in between his foot soldiers and his knights.
Oh! and here is a little detail, the methods `concat`, `push` and `unshift` were
damaged during the battle... so find another way.
Hurry, they are waiting...
> Well, this is a thing unheard of. \
> An Elf would go underground, where a Dwarf dare not. \
> Oh, I'd never hear the end of it.! \
> ― Gimli

17
subjects/security/README.md

@ -0,0 +1,17 @@
## Security
### AND + OR (`&&` + `||`)
Combining `&&` and `||` builds complex logical conditions.
You can use `()` to group them.
### Instructions
The infamous **virus19** is spreading ! As an airport control agent your role is
to ensure that the traveler is safe for his flight.
You must define the `traveler.isImmune` property to `true` if either:
- both `traveler.alreadyHadTheVirus` and `traveler.recovered` are `true`
- or `traveler.isVaccinated` is `true`

25
subjects/seeker-of-truth/README.md

@ -2,15 +2,19 @@
### Truthy and Falsy
In JS, all values are either **truthy** or **falsy**, this means if used in a condition, truthy values will validate the condition while falsy values would not.
In JS, all values are either **truthy** or **falsy**, this means if used in a
condition, truthy values will validate the condition while falsy values would
not.
Here is the list of falsy values:
- `undefined` and `null`
- the numbers `0` and `NaN`
- the empty string `''`
- and the boolean `false` of course
All other values are truthy, note that empty arrays and empty objects are truthy, but the empty string is not.
All other values are truthy, note that empty arrays and empty objects are
truthy, but the empty string is not.
```js
if ('') {
@ -24,7 +28,8 @@ if ('hello') {
### Operator `!`
The `!` (NOT operator) can be used to convert a truthy value to `false` or a falsy value to `true`.
The `!` (NOT operator) can be used to convert a truthy value to `false` or a
falsy value to `true`.
example:
@ -35,16 +40,12 @@ let noMoney = !money
console.log(noMoney) // true
```
In this case, 0 is falsy, so the `!` return the value `true`
In this case, 0 is falsy, so the `!` return the value `true`
### Instructions
R
```js
let truth = 0
Seek the truth and claim your verdict !
if (!truth) {
console.log()
}
```
- Log `'The truth was spoken.'` if the value of the provided variable `truth` is
truthy
- Log `'Lies !!!!'` if the value of the provided variable `truth` is falsy

27
subjects/special-promo/README.md

@ -0,0 +1,27 @@
## Special Promo 🎟
### `&&` (the AND operator)
This operator is used to group conditions:
```js
if (user.role === 'admin' && user.available === 'now') {
console.log('Admin', user.name, 'is available and will help you now !')
}
```
Here, the code will only show the message if **both** conditions are true.
### Instructions
Your traveling company have a new special promo for members between 18 and 25
years old.
Write the `if` condition that will check if the user can benefit the promotion:
- `user.age` must be at least `18`
- `user.age` must be lesser or equal to `25`
- `user.activeMembership` must be `true`
If all of those conditions are true, `console.log` the message
`You can benefit from our special promotion`

19
subjects/spread-the-word/README.md

@ -0,0 +1,19 @@
## 🌟 Spread the Word 💬
### Notions
- [devdocs.io/operators/spread_syntax](https://devdocs.io/javascript/operators/spread_syntax)
### Instructions
Gondor needs help!
To call for help you will have to concat the provided strings and arrays;
`easternmost` (string), `easternBeacons` (array), `centerBeacon` (string),
`westernBeacons` (array) and `westernmost` (string) into the variable array
`beaconsLit` that you will declare. Only one array of burning fires must be left
at the end.
Unfortunately young hobbit, the guards are watching the `Array.concat()`, the
`Array.unshift()` and the `Array.push()` methods. You will have to find another
way...

2
subjects/the-true-king/README.md

@ -1,4 +1,4 @@
## The True King
## The True King 👑
### Instructions

26
subjects/time-to-pay/README.md

@ -0,0 +1,26 @@
## Time to Pay 💸
### `||` (the OR operator)
The other way to group condtions:
```js
if (user.role === 'admin' || user.role === 'moderator') {
console.log(user.name, 'has access to moderation pages.')
}
```
Here, the code will only show the message if **any** conditions are true.
### Instructions
You are selling planes tickets, they all cost `9.99$` you must confirm that the
`customer` has the means to buy this ticket. The `customer` may have enough
`cash` or a `voucher`
Check if the provided variable `customer` can afford the ticket:
- whether he has enough cash (`customer.cash` property)
- or, if he has a voucher (`customer.hasVoucher` property is `true`)
If so, you must increment the provided variable `ticketSold` value by `1`.

43
subjects/to-infinity-and-beyond/README.md

@ -0,0 +1,43 @@
## To Infinity And Beyond
### The `else if` keyword
Last keyword of the serie, this one combine the two previous keywords to allow
to chain conditions:
```js
if (temperature < 8) {
console.log('very cold !')
} else if (temperature < 16) {
console.log('still too cold...')
} else if (temperature < 24) {
console.log('getting warmer')
} else if (temperature < 32) {
console.log('nice :)')
} else {
console.log('Too hot !!!')
}
```
You can chain as mainy as you want, the syntax is similar to the if.
### Instructions
The year is 2042 Elon's dream came true He now has spaceship lines to mars and
to the moon and a big pool of candidates who all want to go to space but there
is still a heavy selection process based on:
- number `candidate.physicalAptitudes` from `0` to `100`
- boolean `candidate.noFamily`
You have to create a condition to go to Mars which is always the most demanded
destination for this destination:
- if the candidate `physicalAptitudes` are below `80`, he must stay on `'earth'`
- only candidates with `noFamily` can go on `'mars'`
- otherwhise they can still go to the `'moon'`
You must log which planet the `candidate` can access
> And there seems to be no sign of intelligent life anywhere. \
> ― Buzz Lightyear

81
subjects/two-can-play-that-game/README.md

@ -0,0 +1,81 @@
## Two can play that game
### Arguments (Continued)
We have seen how to add one argument to the a function, We are now going to see
how to add two (or more).
Remember when `arg1` was added in the parens `()`?
```js
let myFirstFunction = (arg1) => {
console.log(arg1)
}
// Now we call the function
myFirstFunction('using my first arg') // "using my first arg"
```
Well now, all we need to do to add a second argument `arg2` is to add a comma
`,` after `arg1` and then add `arg2`.
```js
let myFirstFunction = (arg1, arg2) => {
//<-arg1 and arg2 are inputed in between the parens
console.log(arg1, arg2)
// ↖ arg1 and arg2 are "transfered" to be the args of console.log()
}
// Now we call the function
myFirstFunction('first arg', 'second arg')
// "first arg"
// "second arg"
```
For more args, you will need to simply repeat the same process. Example with
`arg3` and `arg4`:
```js
let myFirstFunction = (arg1, arg2, arg3, arg4) => {
//<as many arguments as needed
console.log(arg1, arg2, arg3, arg4)
} //<-end of the scope of the function
// Now we call the function
myFirstFunction('first arg', 'second arg', 3, 4)
// "first arg"
// "second arg"
// 3
// 4
```
Finally, please note that you can name your arguments however you please. Just
make sure that you reuse the proper name inside the scope of your function.
Example:
```js
let myFirstFunction = (continent, country, city, temperature) => {
//<as many arguments as needed
console.log(continent, country, city, temperature)
} //<-end of the scope of the function
// Now we call the function
myFirstFunction('Europe', 'France', 'Paris', '30°C')
// "Europe"
// "France"
// "Paris"
// "30°C"
```
### Instructions
You want to conquer the world! (of entertainment).
In this exercise you will have to declare the function `duos`.
This function will take two arguments and will log them together with an `and`
and a `!`
Example: If the `arg1` is `Batman` and `arg2` is `Robin`, the fonction should
log : `Batman and Robin!`
You will then declare the function `duosWork`. This function will take three
arguments and will log them togethers as in the example below. Example: If the
`arg1` is `Batman`, the`arg2` is `Robin`, and the `arg3` is `protect Gotham`.
the fonction should log : `Batman and Robin protect Gotham!`

33
subjects/virus19/README.md

@ -0,0 +1,33 @@
## 🌟 Virus19 🦠
In the previous lessons you have seen some examples of values reassignement
along the way. Here are two more examples:
```js
let mainHouse = { door: 'blue' }
let acidHouse = { door: 'blue' }
mainHouse = 'destroyed'
acidHouse.door = 'red'
```
First, the object `mainHouse` has been replaced by the string `destroyed`.
Second, the door of `acidHouse` has been repainted with the color `red`.
You will now have to find a way to prevent this... A way of "freezing" your
objects if you will...
[Object.freeze](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
### Instructions
Level 4 Alert! A very smart `virus19` has escaped the laboratory! You have 5
mins to fight this virus on two fronts:
- First freeze the object `virus19` so that it cannot mutate!
- Then release the countermeasure by declaring `vaccine` which will be a secure
copy of the object `antivirus`.
> Our Business Is Life Itself \
> ― Umbrella Corporation's slogan

26
subjects/what-else/README.md

@ -1,3 +1,27 @@
## What else ?
if / else + includes?
### The `else` keyword
It allows to execute alternative code if the condition do not match:
```js
if (isEnough) {
console.log('this is enough :)')
} else {
console.log('I want more !!')
}
```
it is like an `if` but you don't have a condition, just add a scope after `{}`
and write code !
### Instructions
You must check if `'George Clooney'` is included in the provided array `vips`
if he is, `console.log` the string `'What else ?'` otherwhise log
`'The only failure is not to try.'`
### Notions
- [includes](https://devdocs.io/javascript/global_objects/array/includes)

106
subjects/what-is-my-purpose/README.md

@ -0,0 +1,106 @@
## What is my purpose?
![robot](https://cdn.discordapp.com/attachments/489466992286498816/828181029772197888/butter-purpose.png)
### Remember Methods?
You have seen how to call functions that were stored in object properties.
Remember this example of function call?:
```js
// ↙ identifier, like variables
console.log('Hello There !') // <- function call happening here
// ↖ open paren + argument + close paren
```
or these ones?:
```js
let roundedValue = Math.round(1.8) // another function call happening here
console.log(roundedValue) // and another one here
```
There, we saw how to call and use _"pre-declared"_ functions.
Here, now, we are going to learn how to declare our owns. This will gives us
even more freedom to build our own logic.
### Declaring a very basic function
We mentioned before that a function had to be either assigned to a variable or
an object property.
We will now declare one in a variable. Let's call it: `myFirstFunction`.
Once a variable is declared; Remember how an array can be recognized with this
syntax : `[]`? or an object with this one : `{}` ?
Well, we will use another syntax for declaring our function. We will do so using
the `ArrowFunctionExpression` syntax : `() => {}`
- So we first put parens `()`, These, are the containers of the `arguments` that
go in the function. For now we will leave them empty with no arguments. (More
on those later on)
- We then add the arrow `=>` which is the distinguishing feature of the
`ArrowFunctionExpression` syntax.
- Finally, we add the curly brackets `{}` to delimite the scope of our newly
created function. Note: They are not always necessary, you will probably find
examples of this function syntax without the `{}`. However, for now because
you are learning. We will put them most of the time.
```js
// ↙ normal variable ↙ beginning of the scope of the function
let myFirstFunction = () => {
// ↖ parens () for arguments and the arrow => for syntax
} // <-end of the scope of the function
```
It's now possible to call this function using the `()`, like any pre-declared
function:
```js
myFirstFunction() // nothing happens
```
This function if called, does not do anything, since it doesn't contain any
code.
### The scope of a function `{}`
Very much like an `if` statement a function has a scope. The scope in between
the curly braces`{}` is where the action happens. Let's add something to the
scope of our function.
```js
let myFirstFunction = () => {
console.log('Calling my first function')
// ↖ some instructions to do when the function is called !
}
```
Now the function if called, display the output the `console.log()`.
```js
myFirstFunction() // "Calling my first function"
```
We actually used a function and gave it this single instruction:
- call another function `console.log()`.
### Instructions
You are a robot made by a scientist called Rick and you want to know your
purpose. We have declared the object `dialogue`. Declare **and call** a function
named `whatIsMyPurpose`.
- This function will display in the console the value of the key `myQuestion` in
the object `dialogue`.
Declare **and call** a function named `theAnswer`.
- This function will display in the console the value of the key `Rick's answer`
in the object `dialogue`.
Hint : Make sure your console is open if you want to see the actual answer :)

20
subjects/wololo/README.md

@ -1,4 +1,4 @@
## 🌟 Wololo
## 🌟 Wololo 🧙
### Converting types
@ -43,9 +43,15 @@ type.
Using the magical power of functions, execute the following conversions:
- Declare a `stringFromNumber` variable of the converted value of `num` to a `string`
- Declare a `stringFromBoolean` variable of the converted value of `bool` to a `string`
- Declare a `numberFromString` variable of the converted value of `str` to a `number`
- Declare a `numberFromBoolean` variable of the converted value of `bool` to a `number`
- Declare a `booleanFromString` variable of the converted value of `str` to a `boolean`
- Declare a `booleanFromNumber` variable of the converted value of `num` to a `boolean`
- Declare a `stringFromNumber` variable of the converted value of `num` to a
`string`
- Declare a `stringFromBoolean` variable of the converted value of `bool` to a
`string`
- Declare a `numberFromString` variable of the converted value of `str` to a
`number`
- Declare a `numberFromBoolean` variable of the converted value of `bool` to a
`number`
- Declare a `booleanFromString` variable of the converted value of `str` to a
`boolean`
- Declare a `booleanFromNumber` variable of the converted value of `num` to a
`boolean`

7
subjects/words/README.md

@ -2,10 +2,11 @@
### Instructions
**Split** the provided variable `sentence` using spaces as separator to create an array of words.
You will assign the result to a `words` variable that you will declare.
**Split** the provided variable `sentence` using spaces as separator to create
an array of words. You will assign the result to a `words` variable that you
will declare.
Hint: Check the link below to see what the method split does and how to use it.
Hint: Check the link below to see what the method split does and how to use it.
### Notions

61
subjects/you-pass-butter/README.md

@ -0,0 +1,61 @@
## You pass butter
### Return value
We are now going to see how to declare a function that returns an argument.
Let's say we declare the variable `ten` the following way.
```js
let ten = 5 + 5
console.log(ten) // 10
```
We could replace those `5` with a very simple function that `returns` this
result. Let's call this function `returnsFive`. Let's not put any arguments in
this function to keep it very basic. The only new concept is the `return`
keyword. This keyword will return the specified value **and** end the function
execution.
```js
let returnsFive = () => {
return 5
// ↖ the keyword `return`, returns the value right after it,
// in this case the number 5.
}
```
Now that the function is declared, we call it where we need it.
```js
let ten = returnsFive() + returnsFive()
console.log(ten) // 10
```
Now a question that you might ask yourself is: What if we had several `return`
keywords in the same function? Well as mentioned before, the `return` also stops
the function execution. So only the first `return` would matter. In fact that
means that anything after the `return` would not be executed. Example:
```js
let returnsFive = () => {
return 5 //ONLY this return is executed. Everything else is forgoten.
return 10 // not executed (useless)
return 'I am useless' // not executed either
console.log('I am also useless') //nor this one
}
let ten = returnsFive() + returnsFive()
console.log(ten) // 10
//exactly the same result as the previous example
```
As you may see, we get exactly the same result as the previous example.
`returnsFive` only returns 5. :)
### Instructions
As Rick's robot, you now know your purpose. (Remember? 'You pass butter.')
Define the function `passButter` that returns `The butter`.
![robot](https://media.discordapp.net/attachments/489466992286498816/828181031991377930/butter-disapointed.png?width=717&height=241)

21
subjects/you-spin-me-round/README.md

@ -5,7 +5,7 @@
Functions in JS allows you to describe multiple `instructions`, in other words,
it's a way to execute code inside your code !
That seems pretty complicated but it is the build block of your programs.
That seems pretty complicated but it is the building block of your programs.
You already have been using a `function` as `console.log` is one ! You can easly
spot them because we stick parens after their identifiers `()`.
@ -21,9 +21,10 @@ console.log('Hello There !')
#### Function name (`identifier` or `property.key`)
The first things that appears in a function is the `identifier`, in fact, in JS,
functions are values of type `function`.
This means that in order to be used a function **must** be either assigned to:
- a variable
functions are values of type `function`. This means that in order to be used a
function **must** be either assigned to:
- a variable
- or an object property
#### Function calling
@ -88,16 +89,16 @@ be passed to `console.log` that will procede to display it.
### Instructions
We have prepared a variable `num`.
Just as a warm up, use this variable `num` as `argument` of some `Math`
functions.
We have prepared a variable `num`. Just as a warm up, use this variable `num` as
`argument` of some `Math` functions.
- Declare a `rounded` variable of `num` rounded value.
- Declare a `truncated` variable of `num` truncated value.
One of the necessary Math function is already used in the lessons examples before the instructions.
Explore the link below to see which others functions the Math object contains in order to find what
you need to complete this exercise.
One of the necessary Math function is already used in the lessons examples
before the instructions. Explore the link below to see which others functions
the Math object contains in order to find what you need to complete this
exercise.
### Notions

Loading…
Cancel
Save