From bc2bd8ab9714c9693c3bbbd9e31b8087ae8df858 Mon Sep 17 00:00:00 2001 From: Anders Hagen Ottersland Date: Mon, 23 Sep 2024 08:45:31 +0200 Subject: [PATCH] done --- src/fizzbuzz.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/fizzbuzz.js b/src/fizzbuzz.js index e3ec3a8..b9fb2c6 100644 --- a/src/fizzbuzz.js +++ b/src/fizzbuzz.js @@ -2,7 +2,29 @@ const answer = [] // Write your code below this line - +for (i = 1; i <= 15; i++) { + let dividable3 = false + let dividable5 = false + if (i % 3 === 0) { + dividable3 = true + } + if (i % 5 === 0) { + dividable5 = true + } + if (dividable3 && dividable5) { + answer.push('FizzBuzz') + continue + } + if (dividable3) { + answer.push('Fizz') + continue + } + if (dividable5) { + answer.push('Buzz') + continue + } + answer.push(i) + }