From 2986de126fec19dd1135c6e9cfd9615b8a2a125b Mon Sep 17 00:00:00 2001 From: Stian Gaustad Date: Fri, 16 Feb 2024 13:58:06 +0100 Subject: [PATCH] Resolved fizzbuzz --- src/fizzbuzz.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/fizzbuzz.js b/src/fizzbuzz.js index e3ec3a8..2f5855c 100644 --- a/src/fizzbuzz.js +++ b/src/fizzbuzz.js @@ -1,10 +1,21 @@ const answer = [] // Write your code below this line +function fizzbuzz(value) { + if (value % 3 === 0 && value % 5 === 0) { + return 'FizzBuzz' + } else if (value % 3 === 0) { + return 'Fizz' + } else if (value % 5 === 0) { + return 'Buzz' + } else { + return value + } +} - - - +for (let i = 1; i <= 15; i++) { + answer.push(fizzbuzz(i)) +} // Don't touch the code below this line, we'll cover it later module.exports = answer