Browse Source

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

Review language piscine jsdata quest c 2
pull/1074/head
Dav Hojt 3 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 ### Instructions
Create a `isPositive` function that takes a number as Create a function named `isPositive` that takes a number as a argument, returning `true` if the number is strictly positive, and `false` otherwise.
parameter and return true if the given number is
stricly positive, or false otherwise
Create the `abs` function that takes one number argument 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()`.
and returns its absolute value.
You are not allowed to use `Math.abs`, make your own.
### Notions ### Notions
- [nan-academy.github.io/js-training/examples/functions.js](https://nan-academy.github.io/js-training/examples/functions.js) - [Functions](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) - [Ternary](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) - [Math.abs](https://devdocs.io/javascript/global_objects/math/abs)
### Code provided ### 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 ```js
Math.abs = undefined Math.abs = undefined

9
subjects/biggie-smalls/README.md

@ -2,11 +2,10 @@
### Instructions ### Instructions
Create 2 variables Create 2 variables:
- `smalls` with the smallest possible `number` value.
- `smalls` with the smallest possible `number` value - `biggie` with the greatest possible `number` value.
- `biggie` with the greatest possible `number` value
### Notions ### 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 ### 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: A block must have the following properties:
- `index` - `index`
- `hash` a computed hash using the concatenation of the `index`, `hash` - `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`.
and stringified `data` and hashing all of it using the provided `hashCode`. - `data`: any valid object.
- `data` the data (not encoded in JSON) - `prev`: the previous block.
- `prev` the previous block - `chain`: a function that accepts `data` as an argument, and creates the next block with it.
- `chain` a function that takes a new `data` and create the next block with it.
### Examples ### Examples
@ -51,11 +47,11 @@ console.log(fork.index) // -> 5
### Notions ### 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 ### 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 ```js
const hashCode = str => const hashCode = str =>

17
subjects/change/README.md

@ -4,23 +4,20 @@
Create 2 functions: Create 2 functions:
- `get`: a function that takes a key and return the corresponding - `get`: a function that takes a key and returns the corresponding value from the `sourceObject`.
value from the sourceObject
- `set`: a function that takes a key and a value update the - `set`: a function that takes a key and a value. Update the value for the corresponding property of the `sourceObject` and return the value.
value for the corresponding property of the sourceObject
and return the set value
### Notions ### Notions
- [nan-academy.github.io/js-training/examples/functions.js](https://nan-academy.github.io/js-training/examples/functions.js) - [Functions](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) - [Data Structures](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) - [Get](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) - [Set](https://nan-academy.github.io/js-training/examples/set.js)
### Code provided ### 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 ```js
const sourceObject = { const sourceObject = {

9
subjects/circular/README.md

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

39
subjects/collections/README.md

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

6
subjects/concat-str/README.md

@ -2,9 +2,9 @@
### Instructions ### 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 ### Notions
- [nan-academy.github.io/js-training/examples/functions.js](https://nan-academy.github.io/js-training/examples/functions.js) - [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) - [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: Create the following constant variables:
- `escapeStr`, that contains the following specials characters: `` ` ``, `\`, `/`, `"`, `'` - `escapeStr`: a `string` which contains the following special characters: `` ` ``, `\`, `/`, `"` and `'`.
- `arr` that is an array containing the values 4 and '2' - `arr`: an array containing the values `4` and `'2'`.
- `obj` that is an object containing a property for each primitives: - `obj`: an object containing primitive values:
- `str` for `String` - `str`: with a `string` value.
- `num` for `Number` - `num`: with a `number` value.
- `bool` for `Boolean` - `bool`: with a `boolean` value.
- `undef` for `undefined` - `undef`: with a `undefined` value.
- A `nested` object that contains - `nested`: an object containing:
- arr: an array of the 3 values: 4, undefined, '2' - `arr`: an array of 3 values: `4`, `undefined` and `'2'`.
- obj: an object with 3 property (str, num & bool) - `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 ### Notions
- Primitive and Operators - Primitive and Operators
- Variables - Variables
- [nan-academy.github.io/js-training/examples/data-structures.js](https://nan-academy.github.io/js-training/examples/data-structures.js) - [Data Structures](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) - [Freeze](https://devdocs.io/javascript/global_objects/object/freeze)

23
subjects/dog-years/README.md

@ -2,20 +2,19 @@
### Instructions ### 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, 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.
calculates how old a dog would be on the given planet.
- `earth` : orbital period 1.0 Earth years, 365.25 Earth days, or 31,557,600 seconds - `earth`: orbital period 1.0 Earth years, 365.25 Earth days, or 31,557,600 seconds.
- `mercury` : orbital period 0.2408467 Earth years - `mercury`: orbital period 0.2408467 Earth years.
- `venus` : orbital period 0.61519726 Earth years - `venus`: orbital period 0.61519726 Earth years.
- `mars` : orbital period 1.8808158 Earth years - `mars`: orbital period 1.8808158 Earth years.
- `jupiter` : orbital period 11.862615 Earth years - `jupiter`: orbital period 11.862615 Earth years.
- `saturn` : orbital period 29.447498 Earth years - `saturn`: orbital period 29.447498 Earth years.
- `uranus` : orbital period 84.016846 Earth years - `uranus`: orbital period 84.016846 Earth years.
- `neptune` : orbital period 164.79132 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. 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 ### Instructions
Hello and welcome to the JS piscine, first you will have to learn Welcome to the JS piscine 👋.
to execute javascript.
Being a special child, JS can run in different **runtime**, what you can First you will have to learn to execute JavaScript.
do with it greatly depend of your runtime.
Luckily you don't need to install anything for that since all you 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.
need is a web browser.
> 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 Let's make a hello world. First we create the JavaScript file
# first we create the javascript file
echo "console.log('Hello World')" > how-2-js.js
# To run JS in your browser you need to import it from an HTML page: ```sh
echo '<script type="module" src="how-2-js.js"></script>' > index.html $ 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 Let's create a simple web server:
&>/dev/null python3 -m http.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 '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 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.
> works, don't be shy and play in it !
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))`, You are all set. If you want to re-execute your script, just refresh.
which will hold all your solutions for this piscine
and just add your 2 generated files to it, we will start slow for now... 🐢
### 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 ### Instructions
Add new function properties to the object `is` to check a value type 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.num`: value is a `number`.
- `is.nan` value is NaN - `is.nan`: value is `NaN`.
- `is.str` value is a string - `is.str`: value is a `string`.
- `is.bool` value is a boolean - `is.bool`: value is a `boolean`.
- `is.undef` value is undefined - `is.undef`: value is `undefined`.
- `is.def` value is defined - `is.def`: value is defined.
- `is.arr` value is an array - `is.arr`: value is an `array`.
- `is.obj` value is a simple object or null objects - `is.obj`: value is a simple object or `null` objects.
- `is.fun` value is a function - `is.fun`: value is a function.
- `is.truthy` value is truthy - `is.truthy`: value is truthy.
- `is.falsy` value is falsy - `is.falsy`: value is falsy.
### Notions ### Notions
- [nan-academy.github.io/js-training/examples/primitive-and-operators](https://nan-academy.github.io/js-training/examples/primitive-and-operators.js) - [Primitives 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) - [typeof](https://devdocs.io/javascript/operators/typeof)
- [developer.mozilla.org/en-US/docs/Glossary/Truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy) - [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) - [Falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy)
### Code provided ### 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 ```js
const is = {} const is = {}

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

@ -4,16 +4,13 @@
Create 3 functions: Create 3 functions:
- a `first` function that takes an array or a string - `first`: that takes an array or a string and returns its first element or character.
and return the first element.
- a `last` function that takes an array or a string - `last`: that takes an array or a string and return its last element or character.
and return the last element.
- a `kiss` function that returns an array of 2 elements - `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.
the last and the first element, in that order
### Notions ### Notions
- [nan-academy.github.io/js-training/examples/data-structures.js](https://nan-academy.github.io/js-training/examples/data-structures.js) - [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) - [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: Write 5 functions:
- `words` that takes a string - `words`: that takes a string, splits it by spaces, and returns an array of those substrings.
and split it into an array of strings on spaces - `sentence`: that takes an array of strings, and joins them with spaces to return a single string.
- `sentence` that takes an array of strings and join them with spaces - `yell`: that takes a string and returns it in upper case.
- `yell` that take a string and return it in upper case - `whisper`: that takes a string and returns it in lower case, surrounded by `*`.
- `whisper` that take a string and return it in lower case - `capitalize`: that takes a string and transforms it so that the first character is upper case, and the subsequent characters are 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
### Notions ### 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 ### Instructions
Create the `max` function that takes 2 number as arguments Create a function named `max` that takes 2 number arguments and returns the largest of the two.
and returns the greatest
> You must not just use `Math.max`, make your own. > You must not just use `Math.max`, make your own.
Create the `min` function that takes 2 number as arguments Create a function named `min` which is the same as `max`, but returns the lowest.
and returns the lowest
> You must not just use `Math.min`, make your own. > You must not just use `Math.min`, make your own.
### Notions ### Notions
- [nan-academy.github.io/js-training/examples/functions](https://nan-academy.github.io/js-training/examples/functions.js) - [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) - [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) - [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) - [Math.max](https://devdocs.io/javascript/global_objects/math/max)
### Code provided ### 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 ```js
Math.min = Math.max = undefined Math.min = Math.max = undefined

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

@ -2,14 +2,13 @@
### Instructions ### Instructions
Create 4 functions Create 4 functions:
- `more` that takes 1 argument and adds 1 to it.
- `more` that takes 1 argument and add 1 to it - `less` that takes 1 argument and subtracts 1 from it.
- `less` that takes 1 argument and subtract 1 to it - `add` that takes 2 arguments and adds them together.
- `add` that takes 2 arguments and add them - `sub` that takes 2 arguments and subtracts the second argument from the first.
- `sub` that takes 2 arguments and subtract them
### Notions ### Notions
- [nan-academy.github.io/js-training/examples/functions](https://nan-academy.github.io/js-training/examples/functions.js) - [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) - [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 ### 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 ### Notions
- [nan-academy.github.io/js-training/examples/set](https://nan-academy.github.io/js-training/examples/set.js) - [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) - [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) - [Data Structures](https://nan-academy.github.io/js-training/examples/data-structures.js)
### Code provided ### 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 ```js
const person = { const person = {

26
subjects/physics/README.md

@ -3,10 +3,12 @@
### Instructions ### Instructions
Isaac Newton has forgotten his laws of physics and needs your help to animate an object on his game. 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 - mass of xx
- Δv of xx - Δv of xx
@ -15,9 +17,18 @@ So he wants to know for an object with :
- distance xx - distance xx
- time xx - time xx
whats the acceleration of that object. Create a function named `getAcceleration` that calculates the velocity of a given object. For example:
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 }` ```js
it must calculate the acceleration. If its not possible to calculate it you must return the string `impossible` {
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 ### Formulas
@ -27,6 +38,7 @@ a = Δv/Δt
a = 2d/t^2 a = 2d/t^2
a = acceleration a = acceleration
m = mass
F = force F = force
Δv = final velocity - initial velocity Δv = final velocity - initial velocity
Δt = final time - initial time Δt = final time - initial time
@ -36,6 +48,6 @@ t = time
### Quote ### 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 Isaac Newton

12
subjects/primitives/README.md

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

10
subjects/returns/README.md

@ -4,11 +4,11 @@
Create the following functions: Create the following functions:
- `id` that takes one argument and return it - `id` that takes one argument and returns it.
- `getLength` that takes an array or a string and return its length - `getLength` that takes an array or a string and returns its length.
### Notions ### Notions
- [nan-academy.github.io/js-training/examples/functions](https://nan-academy.github.io/js-training/examples/functions.js) - [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) - [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) - [Get](https://nan-academy.github.io/js-training/examples/get.js)

17
subjects/sign/README.md

@ -2,23 +2,20 @@
### Instructions ### Instructions
Create the `sign` function that takes one number argument 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.
and return 1 if the number is positive, -1 if the number is negative > You must not just use `Math.sign`, make your own.
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 Create a function named `sameSign` that takes 2 numbers as arguments and returns `true` if they both have the same sign, or false otherwise.
if they both have the same sign, or false otherwise.
### Notions ### Notions
- [nan-academy.github.io/js-training/examples/functions](https://nan-academy.github.io/js-training/examples/functions.js) - [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) - [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) - [Math.sign](https://devdocs.io/javascript/global_objects/math/sign)
### Code provided ### 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 ```js
Math.sign = undefined Math.sign = undefined

Loading…
Cancel
Save