From e42c56ee8eac9a2262bd14b734c24e36341d1dc2 Mon Sep 17 00:00:00 2001 From: John Ferdie Abueg Date: Tue, 24 Sep 2024 10:11:18 +0200 Subject: [PATCH] FIZZBUZZ --- src/fizzbuzz.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/fizzbuzz.js b/src/fizzbuzz.js index e3ec3a8..e33f0e8 100644 --- a/src/fizzbuzz.js +++ b/src/fizzbuzz.js @@ -1,10 +1,19 @@ const answer = [] // Write your code below this line +for (let i = 1; i <= 15; i++) + { + answer.push(FizzBuzzCheck(i)) + } +function FizzBuzzCheck(num) { + if (num % 3 === 0 && num % 5 === 0) return 'FizzBuzz' + else if (num % 3 === 0) return 'Fizz' + else if (num % 5 === 0) return 'Buzz' + else return num +} - - +console.log(answer) // Don't touch the code below this line, we'll cover it later module.exports = answer