Browse Source

discovery-piscine: update subjects

pull/768/head
Clement Denis 3 years ago
parent
commit
d7f3952913
  1. 10
      js/tests/all-caps.json
  2. 2
      js/tests/griswold-the-blacksmith.json
  3. 6
      subjects/capitalized/README.md
  4. 16
      subjects/const/README.md
  5. 4
      subjects/cultural-shift/README.md
  6. 27
      subjects/griswold-the-blacksmith/README.md
  7. 2
      subjects/lines/README.md
  8. 2
      subjects/mirror/README.md
  9. 9
      subjects/pop-art/README.md
  10. 4
      subjects/ratchet-clap/README.md
  11. 2
      subjects/the-great-escape/README.md
  12. 2
      subjects/the-true-king/README.md
  13. 24
      subjects/wololo/README.md
  14. 6
      subjects/words/README.md

10
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`)"
}
]

2
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)" "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)"
}, },
{ {

6
subjects/capitalized/README.md

@ -5,7 +5,7 @@
Declare a `capitalized` variable of the transformed provided variable `word` Declare a `capitalized` variable of the transformed provided variable `word`
where: where:
- First character must be uppercase - The first character must be uppercase
- Rest of the word must be lowercase - 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 !

16
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)

4
subjects/cultural-shift/README.md

@ -7,12 +7,12 @@ Oh noes, Japanese artists have been left out, let's fix this !
### Instructions ### Instructions
You must modify the provided `popArtists` array using a combination of the 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 `'Yayoi Kusama'` at the begining of the array
- Add `'Takashi Murakami'` at the end of the array - Add `'Takashi Murakami'` at the end of the array
### Notions ### 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) - [devdocs.io/javascript/global_objects/array/push](https://devdocs.io/javascript/global_objects/array/push)

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

@ -1,11 +1,11 @@
## Griswold the Blacksmith ## 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**. our own logic and the first block for that are **conditions**.
### The `if` keyword ### 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: right, example:
```js ```js
@ -35,7 +35,7 @@ There are 6 different comparaison opperators:
- `!==` _not equal to_ - `!==` _not equal to_
Every comparaison operator are _like_ functions, they take 2 arguments, one on 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. condition is met, or `false` if it's not.
Since they return value, you can assign them to variables, just like functions Since they return value, you can assign them to variables, just like functions
@ -43,8 +43,8 @@ return values:
```js ```js
let age = 5 let age = 5
let ageEqual5 = age === 5 // age equal to 5 let ageEqual5 = age === 5 // age is equal to 5
let ageNotEqual5 = age !== 5 // age not equal to 5 let ageNotEqual5 = age !== 5 // age is not equal to 5
console.log(ageEqual5) // true console.log(ageEqual5) // true
console.log(ageNotEqual5) // false 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 Scopes are a way to group lines of code, this allow us to do multiple lines of
code if a condition is true. 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)_ ### Indentation `..` _(2 spaces)_
Upon writing code inside a scope, it's an important convention to **indent** it. 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: bad code:
<!-- prettier-ignore-start --> <!-- prettier-ignore-start -->
@ -90,8 +96,8 @@ the code clear.
### Instructions ### Instructions
You are a Griswold the Blacksmith, and you must give the list of items the You are 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: player can buy with the money he has, here is what you are selling:
- arrows for 3 coins - arrows for 3 coins
- boots for 44 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 Declare a `purchasableGoods` array and _conditionally_ push to it all the goods
that the player can buy. that the player can buy.
Use `if` condiations and compare the cost of the goods with the provided Use `if` conditions and compare the cost of the goods with the provided
variable `playerCoins` that contains the number of coins available variable `playerCoins` that contains the number of coins available to
the player.
> You must order elements by price > You must order elements by price

2
subjects/lines/README.md

@ -31,7 +31,7 @@ console.log(splited) // ['','Hellođź‘Ź','Theređź‘Ź', '']
### Instructions ### 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. the number of lines.
- Declare a variable `linesCount` of the number of lines from the provided - Declare a variable `linesCount` of the number of lines from the provided

2
subjects/mirror/README.md

@ -7,7 +7,7 @@ Declare a variable `mirror` of the reversed provided variable `word`.
_example: `desserts` would be `stressed`_ _example: `desserts` would be `stressed`_
> Note that **reverse** only exist on array, you must first find a way to > 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 ### Notions

9
subjects/pop-art/README.md

@ -2,17 +2,14 @@
### Instructions ### Instructions
You must modify the provided `popArtists` array using a combination of the You must modify the provided `popArtists` array using its methods.
`pop`, `push`, `shift` and `unshift` array methods.
> Do not to create a new one, just change it ! > Do not to create a new one, just change it !
- Remove `'Pablo Picasso'` (first) and `'Louise Bourgeois'` (last) from the list - Remove `'Pablo Picasso'` (first) and `'Louise Bourgeois'` (last) from the list
as they are not pop artist as they are not pop artists
- Add `'Andy Warhol'` at the begining of the array
- Add `'Robert Indiana'` at the end of the array
### Notions ### Notions
- [devdocs.io/javascript/global_objects/array/pop](https://devdocs.io/javascript/global_objects/array/pop) - [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)

4
subjects/ratchet-clap/README.md

@ -9,8 +9,8 @@ the đź‘Ź emoji.
Also add one more đź‘Ź at the end of the sentence, for good measure ! 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 ### 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)

2
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 Since they are used for delimiting text, they need a trick to include them in
our text. 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: delimiters:
```js ```js

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

@ -2,5 +2,5 @@
### Instructions ### 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'` value of the provided variable `excalibur` to `'pulled'`

24
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 ? > 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. - `Number` is a function to convert to a number.
- `Boolean` is a function to convert to a boolean. - `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 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 ```js
let str42Placeholder = `${42}` // was this a mistake ? 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 > So there you have it, calling, arguments and return values. Let's see you
> apply all of that now > apply all of that now.
### Instructions ### 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. type.
Using the magical power of functions, execute the following conversions: Using the magical power of functions, execute the following conversions:
- a `stringFromNumber` variable of the converted value of `num` to a `string` - Declare a `stringFromNumber` variable of the converted value of `num` to a `string`
- a `stringFromBoolean` variable of the converted value of `bool` to a `string` - Declare a `stringFromBoolean` variable of the converted value of `bool` to a `string`
- a `numberFromString` variable of the converted value of `str` to a `number` - Declare a `numberFromString` variable of the converted value of `str` to a `number`
- a `numberFromBoolean` variable of the converted value of `bool` to a `number` - Declare a `numberFromBoolean` variable of the converted value of `bool` to a `number`
- a `booleanFromString` variable of the converted value of `str` to a `boolean` - Declare 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 `booleanFromNumber` variable of the converted value of `num` to a `boolean`

6
subjects/words/README.md

@ -2,10 +2,10 @@
### Instructions ### Instructions
**Split** the provided variable `sentence` on spaces to create an array of words **Split** the provided variable `sentence` using spaces as separator to create an array of words.
that you will assign to a `words` variable that you will declare. 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 ### Notions

Loading…
Cancel
Save