diff --git a/js/tests/id_test.js b/js/tests/id_test.js deleted file mode 100644 index 0ea9e96d..00000000 --- a/js/tests/id_test.js +++ /dev/null @@ -1,22 +0,0 @@ -export const tests = [] -const t = (f) => tests.push(f) - -// id is declared and is a function -t(() => typeof id === 'function') - -// id take 1 argument -t(() => id.length === 1) - -// id return numbers back -t(() => id(5) === 5) - -// id return strings back -t(() => id('pouet') === 'pouet') - -// id return itself, why not -t(() => id(id) === id) - -// id return anything really -t((_) => id(_) === _) - -Object.freeze(tests) diff --git a/js/tests/get-length_test.js b/js/tests/mutable.js similarity index 56% rename from js/tests/get-length_test.js rename to js/tests/mutable.js index 2eea9f4f..6797a03c 100644 --- a/js/tests/get-length_test.js +++ b/js/tests/mutable.js @@ -1,12 +1,23 @@ export const tests = [] const t = (f) => tests.push(f) +// id is declared and is a function +t(() => typeof id === 'function') +// id take 1 argument +t(() => id.length === 1) +// id return numbers back +t(() => id(5) === 5) +// id return strings back +t(() => id('pouet') === 'pouet') +// id return itself, why not +t(() => id(id) === id) +// id return anything really +t((_) => id(_) === _) + // handle simple array t(() => getLength([2, 42]) === 2) - // handle mixed array t(() => getLength(['pouet', 4, true]) === 3) - t(() => getLength(Array(100)) === 100) // handle holey array t(() => getLength('salut') === 5) // handle strings t(() => getLength([]) === 0) // handle empty arrays diff --git a/subjects/id.en.md b/subjects/id.en.md deleted file mode 100644 index beeaded0..00000000 --- a/subjects/id.en.md +++ /dev/null @@ -1,10 +0,0 @@ -## Id - -### Instructions - -Create an `id` function that takes one argument and return it - - -### Notions - -- [https://nan-academy.github.io/js-training/examples/functions.js](https://nan-academy.github.io/js-training/examples/functions.js) diff --git a/subjects/get-length.en.md b/subjects/mutable.en.md similarity index 50% rename from subjects/get-length.en.md rename to subjects/mutable.en.md index 5ab344b4..d5a6e5dd 100644 --- a/subjects/get-length.en.md +++ b/subjects/mutable.en.md @@ -1,12 +1,15 @@ -## Get Length +## mutable ### Instructions -Create a `getLength` function that takes an array or a string -and return its length. +Create the following functions: + +- `id` that takes one argument and return it +- `getLength` that takes an array or a string and return its length ### Notions +- [https://nan-academy.github.io/js-training/examples/functions.js](https://nan-academy.github.io/js-training/examples/functions.js) - [https://nan-academy.github.io/js-training/examples/data-structures.js](https://nan-academy.github.io/js-training/examples/data-structures.js) - [https://nan-academy.github.io/js-training/examples/get.js](https://nan-academy.github.io/js-training/examples/get.js)