Browse Source

Merge pull request #1068 from 01-edu/review-language-piscine-jsdata-quest-c-2

Review language piscine jsdata quest c 2
DEV-3198-new-go-exercise-get-digit-len
Dav Hojt 2 years ago committed by GitHub
parent
commit
6187efa78a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      subjects/abs/README.md
  2. 9
      subjects/biggie-smalls/README.md
  3. 22
      subjects/block-chain/README.md
  4. 17
      subjects/change/README.md
  5. 9
      subjects/circular/README.md
  6. 39
      subjects/collections/README.md
  7. 6
      subjects/concat-str/README.md
  8. 29
      subjects/declarations/README.md
  9. 23
      subjects/dog-years/README.md
  10. 60
      subjects/how-2-js/README.md
  11. 36
      subjects/is/README.md
  12. 13
      subjects/last-first-kiss/README.md
  13. 16
      subjects/method-man/README.md
  14. 16
      subjects/min-max/README.md
  15. 15
      subjects/more-or-less/README.md
  16. 14
      subjects/mutability/README.md
  17. 26
      subjects/physics/README.md
  18. 12
      subjects/primitives/README.md
  19. 10
      subjects/returns/README.md
  20. 17
      subjects/sign/README.md

16
subjects/abs/README.md

@ -2,23 +2,19 @@
### Instructions
Create a `isPositive` function that takes a number as
parameter and return true if the given number is
stricly positive, or false otherwise
Create a function named `isPositive` that takes a number as a argument, returning `true` if the number is strictly positive, and `false` otherwise.
Create the `abs` function that takes one number argument
and returns its absolute value.
You are not allowed to use `Math.abs`, make your own.
Create a function named `abs` that takes a number as an argument and returns its absolute value. You must make your own implementation. You **must not** use `Math.abs()`.
### Notions
- [nan-academy.github.io/js-training/examples/functions.js](https://nan-academy.github.io/js-training/examples/functions.js)
- [nan-academy.github.io/js-training/examples/ternary.js](https://nan-academy.github.io/js-training/examples/ternary.js)
- [devdocs.io/javascript/global_objects/math/abs](https://devdocs.io/javascript/global_objects/math/abs)
- [Functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [Ternary](https://nan-academy.github.io/js-training/examples/ternary.js)
- [Math.abs](https://devdocs.io/javascript/global_objects/math/abs)
### Code provided
> all code provided will be added to your solution and does not need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
Math.abs = undefined

9
subjects/biggie-smalls/README.md

@ -2,11 +2,10 @@
### Instructions
Create 2 variables
- `smalls` with the smallest possible `number` value
- `biggie` with the greatest possible `number` value
Create 2 variables:
- `smalls` with the smallest possible `number` value.
- `biggie` with the greatest possible `number` value.
### Notions
- [devdocs.io/javascript-number](https://devdocs.io/javascript-number/)
- [Number](https://devdocs.io/javascript-number/)

22
subjects/block-chain/README.md

@ -2,22 +2,18 @@
### Instructions
Create a `blockChain` that create a block in your very own block chain.
Create a function named `blockChain` that creates a block in your very own block chain. It takes 2 arguments:
the function takes 2 arguments:
- `data` any valid JSON data
- `prev` the previous block, if no block are given it should use the
genesis block: `{ index: 0, hash: '0' }`
- `data`: any valid JSON data.
- `prev`: the previous block, if no block are given it should use the genesis block: `{ index: 0, hash: '0' }`.
A block must have the following properties:
- `index`
- `hash` a computed hash using the concatenation of the `index`, `hash`
and stringified `data` and hashing all of it using the provided `hashCode`.
- `data` the data (not encoded in JSON)
- `prev` the previous block
- `chain` a function that takes a new `data` and create the next block with it.
- `hash`: a computed hash using the `hashCode` function provided. You will need to pass it a concatenation of the block's `index`, the previous block's `hash` and the block's stringified `data`.
- `data`: any valid object.
- `prev`: the previous block.
- `chain`: a function that accepts `data` as an argument, and creates the next block with it.
### Examples
@ -51,11 +47,11 @@ console.log(fork.index) // -> 5
### Notions
- [devdocs.io/javascript/global_objects/json/stringify](https://devdocs.io/javascript/global_objects/json/stringify)
- [JSON.stringify](https://devdocs.io/javascript/global_objects/json/stringify)
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
const hashCode = str =>

17
subjects/change/README.md

@ -4,23 +4,20 @@
Create 2 functions:
- `get`: a function that takes a key and return the corresponding
value from the sourceObject
- `get`: a function that takes a key and returns the corresponding value from the `sourceObject`.
- `set`: a function that takes a key and a value update the
value for the corresponding property of the sourceObject
and return the set value
- `set`: a function that takes a key and a value. Update the value for the corresponding property of the `sourceObject` and return the value.
### Notions
- [nan-academy.github.io/js-training/examples/functions.js](https://nan-academy.github.io/js-training/examples/functions.js)
- [nan-academy.github.io/js-training/examples/data-structures.js](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [nan-academy.github.io/js-training/examples/get.js](https://nan-academy.github.io/js-training/examples/get.js)
- [nan-academy.github.io/js-training/examples/set.js](https://nan-academy.github.io/js-training/examples/set.js)
- [Functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [Data Structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [Get](https://nan-academy.github.io/js-training/examples/get.js)
- [Set](https://nan-academy.github.io/js-training/examples/set.js)
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
const sourceObject = {

9
subjects/circular/README.md

@ -2,11 +2,10 @@
### Instructions
Create an object named `circular` that has a property named `circular` with
itself as the value
Create an object named `circular` that has a property named `circular` with itself as the value.
### Notions
- [nan-academy.github.io/js-training/examples/data-structures.js](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [nan-academy.github.io/js-training/examples/get.js](https://nan-academy.github.io/js-training/examples/get.js)
- [nan-academy.github.io/js-training/examples/set.js](https://nan-academy.github.io/js-training/examples/set.js)
- [Data Structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [Get](https://nan-academy.github.io/js-training/examples/get.js)
- [Sets](https://nan-academy.github.io/js-training/examples/set.js)

39
subjects/collections/README.md

@ -2,22 +2,21 @@
### Instructions
Write a bunch of function to move from one type to another
Write a bunch of functions which converts data from one type to another:
- `arrToSet` from `Array` to `Set`
- `arrToStr` from `Array` to `String`
- `setToArr` from `Set` to `Array`
- `setToStr` from `Set` to `String`
- `strToArr` from `String` to `Array`
- `strToSet` from `String` to `Set`
- `mapToObj` from `Map` to `Object`
- `objToArr` from `Object` to `Array`
- `objToMap` from `Object` to `Map`
- `arrToObj` from `Array` to `Object`
- `strToObj` from `String` to `Object`
- `arrToSet`: from `Array` to `Set`.
- `arrToStr`: from `Array` to `string`.
- `setToArr`: from `Set` to `Array`.
- `setToStr`: from `Set` to `string`.
- `strToArr`: from `string` to `Array`.
- `strToSet`: from `string` to `Set`.
- `mapToObj`: from `Map` to `Object`.
- `objToArr`: from `Object` to `Array`.
- `objToMap`: from `Object` to `Map`.
- `arrToObj`: from `Array` to `Object`.
- `strToObj`: from `string` to `Object`.
and finally write a function `superTypeOf` that unlike `typeof` return
a different value for advanced types like `Map` and `Set`
Finally, write a function named `superTypeOf` that unlike `typeof` returns a specific values for advanced types like `Map` and `Set`.
### Examples
@ -62,9 +61,9 @@ superTypeOf(superTypeOf) // -> 'Function'
### Notions
- [devdocs.io/javascript/operators/typeof](https://devdocs.io/javascript/operators/typeof)
- [devdocs.io/javascript/operators/spread_syntax](https://devdocs.io/javascript/operators/spread_syntax)
- [devdocs.io/javascript/global_objects/map](https://devdocs.io/javascript/global_objects/map)
- [devdocs.io/javascript/global_objects/set](https://devdocs.io/javascript/global_objects/set)
- [devdocs.io/javascript/global_objects/object/fromentries](https://devdocs.io/javascript/global_objects/object/fromentries)
- [devdocs.io/javascript/global_objects/object/entries](https://devdocs.io/javascript/global_objects/object/entries)
- [typeof](https://devdocs.io/javascript/operators/typeof)
- [Spread syntax](https://devdocs.io/javascript/operators/spread_syntax)
- [Map](https://devdocs.io/javascript/global_objects/map)
- [Set](https://devdocs.io/javascript/global_objects/set)
- [Object.fromEntries](https://devdocs.io/javascript/global_objects/object/fromentries)
- [Object.entries](https://devdocs.io/javascript/global_objects/object/entries)

6
subjects/concat-str/README.md

@ -2,9 +2,9 @@
### Instructions
Create a `concatStr` function that takes 2 arguments and concatenate them
Create a function named `concatStr` which takes 2 arguments and concatenates them.
### Notions
- [nan-academy.github.io/js-training/examples/functions.js](https://nan-academy.github.io/js-training/examples/functions.js)
- [nan-academy.github.io/js-training/examples/primitive-and-operators.js](https://nan-academy.github.io/js-training/examples/primitive-and-operators.js)
- [Functions.js](https://nan-academy.github.io/js-training/examples/functions.js)
- [Primitive and Operators.js](https://nan-academy.github.io/js-training/examples/primitive-and-operators.js)

29
subjects/declarations/README.md

@ -4,22 +4,25 @@
Create the following constant variables:
- `escapeStr`, that contains the following specials characters: `` ` ``, `\`, `/`, `"`, `'`
- `arr` that is an array containing the values 4 and '2'
- `obj` that is an object containing a property for each primitives:
- `str` for `String`
- `num` for `Number`
- `bool` for `Boolean`
- `undef` for `undefined`
- A `nested` object that contains
- arr: an array of the 3 values: 4, undefined, '2'
- obj: an object with 3 property (str, num & bool)
- `escapeStr`: a `string` which contains the following special characters: `` ` ``, `\`, `/`, `"` and `'`.
- `arr`: an array containing the values `4` and `'2'`.
- `obj`: an object containing primitive values:
- `str`: with a `string` value.
- `num`: with a `number` value.
- `bool`: with a `boolean` value.
- `undef`: with a `undefined` value.
- `nested`: an object containing:
- `arr`: an array of 3 values: `4`, `undefined` and `'2'`.
- `obj`: an object with 3 properties
- `str` with a `string` value.
- `num` with a `number` value.
- `bool` with a `boolean` value.
`nested`, `arr` and `obj` must be frozen to prevent changes from them.
`nested`, `arr` and `obj` must be frozen, so that their elements or properties cannot be changed.
### Notions
- Primitive and Operators
- Variables
- [nan-academy.github.io/js-training/examples/data-structures.js](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [devdocs.io/javascript/global_objects/object/freeze](https://devdocs.io/javascript/global_objects/object/freeze)
- [Data Structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [Freeze](https://devdocs.io/javascript/global_objects/object/freeze)

23
subjects/dog-years/README.md

@ -2,20 +2,19 @@
### Instructions
Someone once said that a dog makes 7 years for each human year.
Someone once said that a human year is equal to 7 dog years.
Create a `dogYears` function that if given a planet name and an age in seconds,
calculates how old a dog would be on the given planet.
Create a function named `dogYears`, that accepts the name of a planet, and the age of the dog in seconds. Your function should return the age of the dog on that planet in dog years.
- `earth` : orbital period 1.0 Earth years, 365.25 Earth days, or 31,557,600 seconds
- `mercury` : orbital period 0.2408467 Earth years
- `venus` : orbital period 0.61519726 Earth years
- `mars` : orbital period 1.8808158 Earth years
- `jupiter` : orbital period 11.862615 Earth years
- `saturn` : orbital period 29.447498 Earth years
- `uranus` : orbital period 84.016846 Earth years
- `neptune` : orbital period 164.79132 Earth years
- `earth`: orbital period 1.0 Earth years, 365.25 Earth days, or 31,557,600 seconds.
- `mercury`: orbital period 0.2408467 Earth years.
- `venus`: orbital period 0.61519726 Earth years.
- `mars`: orbital period 1.8808158 Earth years.
- `jupiter`: orbital period 11.862615 Earth years.
- `saturn`: orbital period 29.447498 Earth years.
- `uranus`: orbital period 84.016846 Earth years.
- `neptune`: orbital period 164.79132 Earth years.
So if you were told someone that their dog were 1,000,000,000 seconds old, you should be able to say that the dog is 221.82 Earth-years old.
If you were told that a dog was 1,000,000,000 seconds old, you should calculate that the dog would be 221.82 Earth-years old.
You will have to format the number so that the result is rounded like the example above.

60
subjects/how-2-js/README.md

@ -2,48 +2,50 @@
### Instructions
Hello and welcome to the JS piscine, first you will have to learn
to execute javascript.
Welcome to the JS piscine 👋.
Being a special child, JS can run in different **runtime**, what you can
do with it greatly depend of your runtime.
First you will have to learn to execute JavaScript.
Luckily you don't need to install anything for that since all you
need is a web browser.
JavaScript can run in different **runtime** environments. What you can do with JavaScript will greatly depend on the runtime. Even different web browsers (Chrome, Firefox, Safari etc) count as different runtime environments.
> Main runtime for executing JS are: any web browser, NodeJS and Deno.
We'll start by running JavaScript in your browser, so you don't need to install anything to get started.
Let's make a hello world:
Some common JavaScript runtime environments:
- Web browsers
- [Node.js](https://nodejs.org/)
- [Deno](https://deno.land/)
```bash
# first we create the javascript file
echo "console.log('Hello World')" > how-2-js.js
Let's make a hello world. First we create the JavaScript file
# To run JS in your browser you need to import it from an HTML page:
echo '<script type="module" src="how-2-js.js"></script>' > index.html
```sh
$ echo "console.log('Hello World')" > how-2-js.js
```
To run JavaScript in your browser, you can import it into a HTML page:
```sh
$ echo '<script type="module" src="how-2-js.js"></script>' > index.html
```
# Finally let's create a simple web server
&>/dev/null python3 -m http.server &
Let's create a simple web server:
```sh
$ &>/dev/null python3 -m http.server &
```
# Now open your browser at the specified port
Now open your browser at the specified port. You'll use an appropriate command for your system:
- Linux: `xdg-open`
- macOS: `open`
- Windows: `start`
```sh
xdg-open 'http://localhost:8000'
```
> `xdg-open` find your default application for the given argument
> on mac it's just `open` and it's `start` on windows
You can now open your web browser console (`ctrl`+`shift`+`i`)
and you should see your hello world.
> The console is a very handy place to test code and explore how the language
> works, don't be shy and play in it !
You can now open your web browser console. From Google Chrome, press **Command+Option+J** (Mac) or **Control+Shift+J** (Windows, Linux, ChromeOS), and you should see your hello world.
Great ! you are all set, if you want to re-execute your script, just refresh.
The console is a handy place to test your code.
You now just have to create a repository named `((ROOT))`,
which will hold all your solutions for this piscine
and just add your 2 generated files to it, we will start slow for now... 🐢
You are all set. If you want to re-execute your script, just refresh.
### Recommendation
Create a repository named `((ROOT))` which will hold all your solutions for this piscine. Add your 2 generated files to it.
Videos designed to give **hints** are assigned to each quest. It is strongly suggested to watch them as you go.
We'll start slow for now... 🐢

36
subjects/is/README.md

@ -2,30 +2,30 @@
### Instructions
Add new function properties to the object `is` to check a value type
- `is.num` value is a number
- `is.nan` value is NaN
- `is.str` value is a string
- `is.bool` value is a boolean
- `is.undef` value is undefined
- `is.def` value is defined
- `is.arr` value is an array
- `is.obj` value is a simple object or null objects
- `is.fun` value is a function
- `is.truthy` value is truthy
- `is.falsy` value is falsy
Add new function properties to the `is` object to check value types. Each function should take one argument, and return a `boolean`.
- `is.num`: value is a `number`.
- `is.nan`: value is `NaN`.
- `is.str`: value is a `string`.
- `is.bool`: value is a `boolean`.
- `is.undef`: value is `undefined`.
- `is.def`: value is defined.
- `is.arr`: value is an `array`.
- `is.obj`: value is a simple object or `null` objects.
- `is.fun`: value is a function.
- `is.truthy`: value is truthy.
- `is.falsy`: value is falsy.
### Notions
- [nan-academy.github.io/js-training/examples/primitive-and-operators](https://nan-academy.github.io/js-training/examples/primitive-and-operators.js)
- [devdocs.io/javascript/operators/typeof](https://devdocs.io/javascript/operators/typeof)
- [developer.mozilla.org/en-US/docs/Glossary/Truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy)
- [developer.mozilla.org/en-US/docs/Glossary/Falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy)
- [Primitives and operators](https://nan-academy.github.io/js-training/examples/primitive-and-operators.js)
- [typeof](https://devdocs.io/javascript/operators/typeof)
- [Truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy)
- [Falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy)
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
const is = {}

13
subjects/last-first-kiss/README.md

@ -4,16 +4,13 @@
Create 3 functions:
- a `first` function that takes an array or a string
and return the first element.
- `first`: that takes an array or a string and returns its first element or character.
- a `last` function that takes an array or a string
and return the last element.
- `last`: that takes an array or a string and return its last element or character.
- a `kiss` function that returns an array of 2 elements
the last and the first element, in that order
- `kiss`: that takes an array or string, and returns an array of 2 elements. The returned array should contain the last and first elements or characters, in that order.
### Notions
- [nan-academy.github.io/js-training/examples/data-structures.js](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [nan-academy.github.io/js-training/examples/get.js](https://nan-academy.github.io/js-training/examples/get.js)
- [Data Structures.js](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [Get.js](https://nan-academy.github.io/js-training/examples/get.js)

16
subjects/method-man/README.md

@ -4,16 +4,12 @@
Write 5 functions:
- `words` that takes a string
and split it into an array of strings on spaces
- `sentence` that takes an array of strings and join them with spaces
- `yell` that take a string and return it in upper case
- `whisper` that take a string and return it in lower case
and surround it with `*`
- Create a `capitalize` function that takes a string
and transforms it to upper case only for the first letter,
and in lowercase for the rest of the string
- `words`: that takes a string, splits it by spaces, and returns an array of those substrings.
- `sentence`: that takes an array of strings, and joins them with spaces to return a single string.
- `yell`: that takes a string and returns it in upper case.
- `whisper`: that takes a string and returns it in lower case, surrounded by `*`.
- `capitalize`: that takes a string and transforms it so that the first character is upper case, and the subsequent characters are lower case.
### Notions
- [nan-academy.github.io/js-training/examples/methods.js](https://nan-academy.github.io/js-training/examples/methods.js)
- [Methods](https://nan-academy.github.io/js-training/examples/methods.js)

16
subjects/min-max/README.md

@ -2,26 +2,24 @@
### Instructions
Create the `max` function that takes 2 number as arguments
and returns the greatest
Create a function named `max` that takes 2 number arguments and returns the largest of the two.
> You must not just use `Math.max`, make your own.
Create the `min` function that takes 2 number as arguments
and returns the lowest
Create a function named `min` which is the same as `max`, but returns the lowest.
> You must not just use `Math.min`, make your own.
### Notions
- [nan-academy.github.io/js-training/examples/functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [nan-academy.github.io/js-training/examples/ternary](https://nan-academy.github.io/js-training/examples/ternary.js)
- [devdocs.io/javascript/global_objects/math/min](https://devdocs.io/javascript/global_objects/math/min)
- [devdocs.io/javascript/global_objects/math/max](https://devdocs.io/javascript/global_objects/math/max)
- [Functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [Ternary](https://nan-academy.github.io/js-training/examples/ternary.js)
- [Math.min](https://devdocs.io/javascript/global_objects/math/min)
- [Math.max](https://devdocs.io/javascript/global_objects/math/max)
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
Math.min = Math.max = undefined

15
subjects/more-or-less/README.md

@ -2,14 +2,13 @@
### Instructions
Create 4 functions
- `more` that takes 1 argument and add 1 to it
- `less` that takes 1 argument and subtract 1 to it
- `add` that takes 2 arguments and add them
- `sub` that takes 2 arguments and subtract them
Create 4 functions:
- `more` that takes 1 argument and adds 1 to it.
- `less` that takes 1 argument and subtracts 1 from it.
- `add` that takes 2 arguments and adds them together.
- `sub` that takes 2 arguments and subtracts the second argument from the first.
### Notions
- [nan-academy.github.io/js-training/examples/functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [nan-academy.github.io/js-training/examples/primitive-and-operators](https://nan-academy.github.io/js-training/examples/primitive-and-operators.js)
- [Functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [Primitives and Operators](https://nan-academy.github.io/js-training/examples/primitive-and-operators.js)

14
subjects/mutability/README.md

@ -2,21 +2,21 @@
### Instructions
Create three copies of the person object called `clone1`, `clone2` and `samePerson`.
Create three copies of the `person` object named `clone1`, `clone2` and `samePerson`.
Increase by one the property age of `person` and set his country to `'FR'`.
Increase the `age` of `person` by one, and set its `country` to `'FR'`.
A way must be found to have `clone1` and `clone2` keep the original values while `samePerson` changes with `person`.
You must find a way to keep the original values of `clone1` and `clone2`. The values of `samePerson` should change when `person` is changed.
### Notions
- [nan-academy.github.io/js-training/examples/set](https://nan-academy.github.io/js-training/examples/set.js)
- [nan-academy.github.io/js-training/examples/get](https://nan-academy.github.io/js-training/examples/get.js)
- [nan-academy.github.io/js-training/examples/data-structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [Set](https://nan-academy.github.io/js-training/examples/set.js)
- [Get](https://nan-academy.github.io/js-training/examples/get.js)
- [Data Structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
const person = {

26
subjects/physics/README.md

@ -3,10 +3,12 @@
### Instructions
Isaac Newton has forgotten his laws of physics and needs your help to animate an object on his game.
He must use the Second Law of Motion that states, when the forces acting on an object are unbalanced, the object will accelerate.
This acceleration is dependent upon the force that act upon the object and the object's mass.
So he wants to know for an object with :
He must use the Second Law of Motion that states, "when the forces acting on an object are unbalanced, the object will accelerate."
This acceleration is dependent upon the force that acts upon the object and the object's mass.
So he wants to know what the acceleration of that object is, depending on its properties:
- mass of xx
- Δv of xx
@ -15,9 +17,18 @@ So he wants to know for an object with :
- distance xx
- time xx
whats the acceleration of that object.
Create a function called `getAcceleration` that given an object with the values of `{ f: 10, m: 5, Δv: 100, Δt: 50, t:1, d: 10 }`
it must calculate the acceleration. If its not possible to calculate it you must return the string `impossible`
Create a function named `getAcceleration` that calculates the velocity of a given object. For example:
```js
{
f: 10,
m: 5,
Δv: 100,
Δt: 50,
t:1,
d: 10
}
```
If its not possible to calculate it, it must return the string `"impossible"`.
### Formulas
@ -27,6 +38,7 @@ a = Δv/Δt
a = 2d/t^2
a = acceleration
m = mass
F = force
Δv = final velocity - initial velocity
Δt = final time - initial time
@ -36,6 +48,6 @@ t = time
### Quote
Truth is ever to be found in simplicity, and not in the multiplicity and confusion of things
_"Truth is ever to be found in simplicity, and not in the multiplicity and confusion of things."_
Isaac Newton

12
subjects/primitives/README.md

@ -2,14 +2,14 @@
### Instructions
Create a constant variable for each primitives:
Create a constant variable for each of the following primitive types:
- `str` for `String`
- `num` for `Number`
- `bool` for `Boolean`
- `str` for `string`
- `num` for `number`
- `bool` for `boolean`
- `undef` for `undefined`
### 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)
- [Primitives and operators](https://nan-academy.github.io/js-training/examples/primitive-and-operators.js)
- [Variables](https://nan-academy.github.io/js-training/examples/variables.js)

10
subjects/returns/README.md

@ -4,11 +4,11 @@
Create the following functions:
- `id` that takes one argument and return it
- `getLength` that takes an array or a string and return its length
- `id` that takes one argument and returns it.
- `getLength` that takes an array or a string and returns its length.
### Notions
- [nan-academy.github.io/js-training/examples/functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [nan-academy.github.io/js-training/examples/data-structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [nan-academy.github.io/js-training/examples/get](https://nan-academy.github.io/js-training/examples/get.js)
- [Functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [Data Structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
- [Get](https://nan-academy.github.io/js-training/examples/get.js)

17
subjects/sign/README.md

@ -2,23 +2,20 @@
### Instructions
Create the `sign` function that takes one number argument
and return 1 if the number is positive, -1 if the number is negative
and 0 if the number is exactly 0
You must not just use `Math.sign`, make your own.
Create a function named `sign` that takes one number argument; returning `1` if the number is positive, `-1` if the number is negative and `0` if the number is exactly 0.
> You must not just use `Math.sign`, make your own.
Create the `sameSign` function that takes 2 numbers as arguments and return true
if they both have the same sign, or false otherwise.
Create a function named `sameSign` that takes 2 numbers as arguments and returns `true` if they both have the same sign, or false otherwise.
### Notions
- [nan-academy.github.io/js-training/examples/functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [nan-academy.github.io/js-training/examples/if-else](https://nan-academy.github.io/js-training/examples/if-else.js)
- [devdocs.io/javascript/global_objects/math/sign](https://devdocs.io/javascript/global_objects/math/sign)
- [Functions](https://nan-academy.github.io/js-training/examples/functions.js)
- [If-else](https://nan-academy.github.io/js-training/examples/if-else.js)
- [Math.sign](https://devdocs.io/javascript/global_objects/math/sign)
### Code provided
> all code provided will be added to your solution and doesn't need to be submited.
> The provided code will be added to your solution, and does not need to be submitted.
```js
Math.sign = undefined

Loading…
Cancel
Save