From d7f39529137e089fea44a1eeaf53369ac6427537 Mon Sep 17 00:00:00 2001 From: Clement Denis Date: Wed, 31 Mar 2021 18:25:24 +0100 Subject: [PATCH] discovery-piscine: update subjects --- js/tests/all-caps.json | 10 ++++++++ js/tests/griswold-the-blacksmith.json | 2 +- subjects/capitalized/README.md | 6 ++--- subjects/const/README.md | 16 +++++++++++++ subjects/cultural-shift/README.md | 4 ++-- subjects/griswold-the-blacksmith/README.md | 27 ++++++++++++++-------- subjects/lines/README.md | 2 +- subjects/mirror/README.md | 2 +- subjects/pop-art/README.md | 9 +++----- subjects/ratchet-clap/README.md | 4 ++-- subjects/the-great-escape/README.md | 2 +- subjects/the-true-king/README.md | 2 +- subjects/wololo/README.md | 24 +++++++++---------- subjects/words/README.md | 6 ++--- 14 files changed, 73 insertions(+), 43 deletions(-) create mode 100644 js/tests/all-caps.json create mode 100644 subjects/const/README.md diff --git a/js/tests/all-caps.json b/js/tests/all-caps.json new file mode 100644 index 00000000..36cb0d0c --- /dev/null +++ b/js/tests/all-caps.json @@ -0,0 +1,10 @@ +[ + { + "description": "Should work on mixed case", + "code": "let message = 'YoU cAn CaLl Me YoUr MaJeStY!'\n\n// Your code\n\nequal(noCaps, 'you can call me your majesty!')\nequal(allCaps, 'YOU CAN CALL ME YOUR MAJESTY!')" + }, + { + "description": "Should work on mixed case", + "code": "let message = `DoN'T tAlK aBoUt My MoMs, Yo`\n\n// Your code\n\nequal(noCaps, `don't talk about my moms, yo`)\nequal(allCaps, `DON'T TALK ABOUT MY MOMS, YO`)" + } +] \ No newline at end of file diff --git a/js/tests/griswold-the-blacksmith.json b/js/tests/griswold-the-blacksmith.json index 2d6232c0..e69cbf09 100644 --- a/js/tests/griswold-the-blacksmith.json +++ b/js/tests/griswold-the-blacksmith.json @@ -1,6 +1,6 @@ [ { - "description": "if the player can't buy anyting, the array should be empty", + "description": "if the player can't buy anything, the array should be empty", "code": "let playerCoins = 2\n\n// Your code\n\nif (!Array.isArray(purchasableGoods)) {\n throw Error(`purchasableGoods must be declared and an array`)\n}\n\nequal(purchasableGoods.length, 0)" }, { diff --git a/subjects/capitalized/README.md b/subjects/capitalized/README.md index 0fe7793b..438bb023 100644 --- a/subjects/capitalized/README.md +++ b/subjects/capitalized/README.md @@ -5,7 +5,7 @@ Declare a `capitalized` variable of the transformed provided variable `word` where: -- First character must be uppercase -- Rest of the word must be lowercase +- The first character must be uppercase +- The rest of the word must be lowercase -> No new notions here, apply some of your knew knowledge ! +> No new notions here, apply some of your new knowledge ! diff --git a/subjects/const/README.md b/subjects/const/README.md new file mode 100644 index 00000000..7a44521a --- /dev/null +++ b/subjects/const/README.md @@ -0,0 +1,16 @@ +## Primitives + +### Instructions + +Create a variable for each primitives: +- use the identifier `age` for `Number` +- use the identifier `name` for `String` +- use the identifier `cool` for `Boolean` + + +### Notions + +- [nan-academy.github.io/js-training/examples/primitive-and-operators](https://nan-academy.github.io/js-training/examples/primitive-and-operators.js) +- [nan-academy.github.io/js-training/examples/variables](https://nan-academy.github.io/js-training/examples/variables.js) + + diff --git a/subjects/cultural-shift/README.md b/subjects/cultural-shift/README.md index 2b34453b..0d92f8aa 100644 --- a/subjects/cultural-shift/README.md +++ b/subjects/cultural-shift/README.md @@ -7,12 +7,12 @@ Oh noes, Japanese artists have been left out, let's fix this ! ### Instructions You must modify the provided `popArtists` array using a combination of the -`push` and `shift` array methods. +`push` and `unshift` array methods. - Add `'Yayoi Kusama'` at the begining of the array - Add `'Takashi Murakami'` at the end of the array ### Notions -- [devdocs.io/javascript/global_objects/array/shift](https://devdocs.io/javascript/global_objects/array/shift) +- [devdocs.io/javascript/global_objects/array/unshift](https://devdocs.io/javascript/global_objects/array/unshift) - [devdocs.io/javascript/global_objects/array/push](https://devdocs.io/javascript/global_objects/array/push) diff --git a/subjects/griswold-the-blacksmith/README.md b/subjects/griswold-the-blacksmith/README.md index 6c018382..36697018 100644 --- a/subjects/griswold-the-blacksmith/README.md +++ b/subjects/griswold-the-blacksmith/README.md @@ -1,11 +1,11 @@ ## Griswold the Blacksmith -Methods and built-in functions are good, but must of the time we have to write +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**. ### The `if` keyword -The `if` keyword allow you to run lines of code _only if_ the condition is +The `if` keyword allows you to run lines of code _only if_ the condition is right, example: ```js @@ -35,7 +35,7 @@ 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 return a boolean value. Either `true`, the +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 @@ -43,8 +43,8 @@ return values: ```js let age = 5 -let ageEqual5 = age === 5 // age equal to 5 -let ageNotEqual5 = age !== 5 // age not equal to 5 +let ageEqual5 = age === 5 // age is equal to 5 +let ageNotEqual5 = age !== 5 // age is not equal to 5 console.log(ageEqual5) // true console.log(ageNotEqual5) // false ``` @@ -59,11 +59,17 @@ ends at the enclosing `}` a few lines after. 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 + console.log('You are over 48 years old') +} // <- end of the scope of the if condition +``` + ### Indentation `..` _(2 spaces)_ Upon writing code inside a scope, it's an important convention to **indent** it. -Indenting is when spaces are added at the beging of the line, here an example of +Indenting is when spaces are added at the beginning of the line, here is an example of bad code: @@ -90,8 +96,8 @@ the code clear. ### Instructions -You are a Griswold the Blacksmith, and you must give the list of items the -player can buy for the money he got, 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 @@ -100,7 +106,8 @@ player can buy for the money he got, 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` condiations and compare the cost of the goods with the provided -variable `playerCoins` that contains the number of coins available +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 diff --git a/subjects/lines/README.md b/subjects/lines/README.md index 8617fdcb..37b73ea5 100644 --- a/subjects/lines/README.md +++ b/subjects/lines/README.md @@ -31,7 +31,7 @@ console.log(splited) // ['','Hello๐Ÿ‘','There๐Ÿ‘', ''] ### Instructions -You have been recruted to analyse a bunch of poems, your fist task is to count +You have been recruted to analyse a bunch of poems, your first task is to count the number of lines. - Declare a variable `linesCount` of the number of lines from the provided diff --git a/subjects/mirror/README.md b/subjects/mirror/README.md index 05b3adff..3cb20ed0 100644 --- a/subjects/mirror/README.md +++ b/subjects/mirror/README.md @@ -7,7 +7,7 @@ Declare a variable `mirror` of the reversed provided variable `word`. _example: `desserts` would be `stressed`_ > Note that **reverse** only exist on array, you must first find a way to -> convert the word too an array to use it ! +> convert the word to an array to use it ! ### Notions diff --git a/subjects/pop-art/README.md b/subjects/pop-art/README.md index 288b1e91..8b830838 100644 --- a/subjects/pop-art/README.md +++ b/subjects/pop-art/README.md @@ -2,17 +2,14 @@ ### Instructions -You must modify the provided `popArtists` array using a combination of the -`pop`, `push`, `shift` and `unshift` array methods. +You must modify the provided `popArtists` array using its methods. > Do not to create a new one, just change it ! - Remove `'Pablo Picasso'` (first) and `'Louise Bourgeois'` (last) from the list - as they are not pop artist -- Add `'Andy Warhol'` at the begining of the array -- Add `'Robert Indiana'` at the end of the array + as they are not pop artists ### Notions - [devdocs.io/javascript/global_objects/array/pop](https://devdocs.io/javascript/global_objects/array/pop) -- [devdocs.io/javascript/global_objects/array/unshift](https://devdocs.io/javascript/global_objects/array/unshift) +- [devdocs.io/javascript/global_objects/array/shift](https://devdocs.io/javascript/global_objects/array/shift) diff --git a/subjects/ratchet-clap/README.md b/subjects/ratchet-clap/README.md index 66decd1c..cad617ea 100644 --- a/subjects/ratchet-clap/README.md +++ b/subjects/ratchet-clap/README.md @@ -9,8 +9,8 @@ the ๐Ÿ‘ emoji. Also add one more ๐Ÿ‘ at the end of the sentence, for good measure ! -Assign the result in a `ratchetClap` variable +Assign the result in a `ratchetClap` variable. ### Notions -- [devdocs.io/javascript/global_objects/string/join](https://devdocs.io/javascript/global_objects/string/join) +- [devdocs.io/javascript/global_objects/array/join](https://devdocs.io/javascript/global_objects/array/join) diff --git a/subjects/the-great-escape/README.md b/subjects/the-great-escape/README.md index 51d418a0..db98da44 100644 --- a/subjects/the-great-escape/README.md +++ b/subjects/the-great-escape/README.md @@ -7,7 +7,7 @@ Since they are used for delimiting text, they need a trick to include them in our text. -For example, we want a `'` _(single quote)_ in our text, but use them as +For example, we want a `'` _(single quote)_ in or text, but use them as delimiters: ```js diff --git a/subjects/the-true-king/README.md b/subjects/the-true-king/README.md index 27859dcc..0d518a05 100644 --- a/subjects/the-true-king/README.md +++ b/subjects/the-true-king/README.md @@ -2,5 +2,5 @@ ### Instructions -if the provided variable `name` is the string `'Arthur'` you must change the +If the provided variable `name` is the string `'Arthur'` you must change the value of the provided variable `excalibur` to `'pulled'` diff --git a/subjects/wololo/README.md b/subjects/wololo/README.md index 7812b4d0..f45b3fe5 100644 --- a/subjects/wololo/README.md +++ b/subjects/wololo/README.md @@ -13,7 +13,7 @@ For example we can not multiply strings, if you try to do `'hello' * 2` or > Well what were you expecting really ? `'hellohello'` maybe ? -So sometimes it is usefull to go from strings to number to boolean _and back !_ +So sometimes it is useful to go from strings to number to boolean _and back !_ - `Number` is a function to convert to a number. - `Boolean` is a function to convert to a boolean. @@ -26,26 +26,26 @@ String(true) ``` One other way we can use `placeholders` for, is to convert from any values to a -string, but using functions is more clear than abusing placeholder syntax: +string, but using functions is clearer than abusing placeholder syntax: ```js let str42Placeholder = `${42}` // was this a mistake ? -let str42Function = String(42) // ah okey we want a string ! +let str42Function = String(42) // ah okay we want a string ! ``` -> so there you have it, calling, arguments and return values, let's see you -> apply all of that now +> So there you have it, calling, arguments and return values. Let's see you +> apply all of that now. ### Instructions -For this exercise, we provide 3 variables `num`, `bool` and `str` of a matching +For this exercise, we provided 3 variables `num`, `bool` and `str` of a matching type. Using the magical power of functions, execute the following conversions: -- a `stringFromNumber` variable of the converted value of `num` to a `string` -- a `stringFromBoolean` variable of the converted value of `bool` to a `string` -- a `numberFromString` variable of the converted value of `str` to a `number` -- a `numberFromBoolean` variable of the converted value of `bool` to a `number` -- a `booleanFromString` variable of the converted value of `str` to a `boolean` -- 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` diff --git a/subjects/words/README.md b/subjects/words/README.md index ff27b417..af29c6b5 100644 --- a/subjects/words/README.md +++ b/subjects/words/README.md @@ -2,10 +2,10 @@ ### Instructions -**Split** the provided variable `sentence` on spaces to create an array of words -that you will assign 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. +Hint: Check the link below to see what the method split does and how to use it. ### Notions