From 0c54b2fcc9e09dd5097650f793ce3148d5db28d4 Mon Sep 17 00:00:00 2001 From: Malte Date: Mon, 23 Sep 2024 10:14:40 +0200 Subject: [PATCH] all green --- src/fizzbuzz.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/fizzbuzz.js b/src/fizzbuzz.js index e3ec3a8..0aa856b 100644 --- a/src/fizzbuzz.js +++ b/src/fizzbuzz.js @@ -2,9 +2,23 @@ const answer = [] // Write your code below this line +const list = Array.from({ length: 15 }, (_, i) => i + 1) +console.log(list) +list.forEach((x, index) => { + if (x % 3 === 0) { + list[index] = 'Fizz' + } + if (x % 5 === 0) { + list[index] = 'Buzz' + } + if (x % 5 === 0 && x % 3 === 0) { + list[index] = 'FizzBuzz' + } +}) +console.log(list) - +answer.push(...list) // Don't touch the code below this line, we'll cover it later module.exports = answer