forked from root/public
2 changed files with 53 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||||||
|
import { promisify } from 'util' |
||||||
|
import * as cp from 'child_process' |
||||||
|
|
||||||
|
const exec = promisify(cp.exec) |
||||||
|
|
||||||
|
export const tests = [] |
||||||
|
|
||||||
|
tests.push(async ({ path, eq }) => { |
||||||
|
const { stdout } = await exec(`node ${path} discovery`) |
||||||
|
return eq(stdout.trim(), 'verydisco') |
||||||
|
}) |
||||||
|
|
||||||
|
tests.push(async ({ path, eq }) => { |
||||||
|
const { stdout } = await exec(`node ${path} "kiss cool"`) |
||||||
|
return eq(stdout.trim(), "sski olco") |
||||||
|
}) |
||||||
|
|
||||||
|
tests.push(async ({ path, eq }) => { |
||||||
|
const { stdout } = await exec(`node ${path} kiss cool`) |
||||||
|
return eq(stdout.trim(), "sski") |
||||||
|
}) |
||||||
|
|
||||||
|
tests.push(async ({ path, eq }) => { |
||||||
|
const { stdout } = await exec(`node ${path} "Node is awesome"`) |
||||||
|
return eq(stdout.trim(), "deNo si omeawes") |
||||||
|
}) |
@ -0,0 +1,27 @@ |
|||||||
|
## verydisco |
||||||
|
|
||||||
|
### Instructions |
||||||
|
|
||||||
|
Create a `verydisco.mjs` script that : |
||||||
|
- takes 1 argument from the command line |
||||||
|
- makes it very disco: |
||||||
|
- cut this argument in 2 (rounded up), |
||||||
|
- re-compose a word by concatenating the chunks in the other order |
||||||
|
- display the result in console |
||||||
|
|
||||||
|
If the argument passed is a sentence, each word of the sentence must be very disco. |
||||||
|
|
||||||
|
For example: |
||||||
|
- `discovery` would print `verydisco` (🕺🏼) in console. |
||||||
|
- `Node is awesome` would print `deNo si omeawes` in console. |
||||||
|
|
||||||
|
### Notions |
||||||
|
|
||||||
|
- [Node process: `argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) |
||||||
|
- [nan-academy.github.io/js-training/examples/methods.js](https://github.com/nan-academy/js-training/blob/master/examples/methods.js) |
||||||
|
- [`slice()` method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) |
||||||
|
- [`includes()` method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) |
||||||
|
- [`split()` method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) |
||||||
|
- [`join()` method](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join) |
||||||
|
|
||||||
|
<!-- and also Math.ceil ? --> |
Loading…
Reference in new issue