From d57c9e3a21a0f81425a4881dcc8599c90cc9274c Mon Sep 17 00:00:00 2001 From: Clement Denis Date: Wed, 5 May 2021 23:51:33 +0100 Subject: [PATCH] discovery-js: add additional loop exercise --- js/tests/count-up-to.json | 10 ++++++++++ subjects/count-up-to/README.md | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 js/tests/count-up-to.json create mode 100644 subjects/count-up-to/README.md diff --git a/js/tests/count-up-to.json b/js/tests/count-up-to.json new file mode 100644 index 00000000..15e2afce --- /dev/null +++ b/js/tests/count-up-to.json @@ -0,0 +1,10 @@ +[ + { + "description": "Count up to 3", + "code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nupTo(3)\nequal(\n args.flat().join('\\n'),\n `0\n1\n2\n3`,\n)" + }, + { + "description": "Count up to 11", + "code": "const args = saveArguments(console, 'log')\n\n// Your code\n\nupTo(11)\nequal(\n args.flat().join('\\n'),\n `0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11`,\n)" + } +] \ No newline at end of file diff --git a/subjects/count-up-to/README.md b/subjects/count-up-to/README.md new file mode 100644 index 00000000..164a3552 --- /dev/null +++ b/subjects/count-up-to/README.md @@ -0,0 +1,10 @@ +## Count up to + +### Instructions + +Declare `upTo` function that takes an `end` number argument. + +You must log each number starting at `0` until you reach the `end` value +(included) + +> Example: `upTo(3)` would log: 0 1 2 3