Skip to content

Commit

Permalink
Completed
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Wiik committed Sep 23, 2024
1 parent 164ec37 commit 7acef32
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/fizzbuzz.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,39 @@ const answer = []

// Write your code below this line

/*
Inside the `src/fizzbuzz.js` file, write a program that populates the `answer` array with numbers from 1 to 15, *except*:
- When the number is a multiple of three (e.g. 3, 6, 9, etc.), the number should be replaced with the word `Fizz`
- When the number is a multiple of five (e.g. 5, 10, etc.), the number should be replaced with the word `Buzz`
- When the number is a multiple of both three *and* five (e.g. 15), the number should be replaced with the word `FizzBuzz`
*/

for (let i = 0; i < 15; i++) {
let insert = ''
let number = i + 1
if (number % 3 === 0) {
insert = insert.concat('Fizz')
if (number % 5 === 0) {
insert = insert.concat('Buzz')
}
answer[i] = insert
continue
}

else if (number % 5 === 0) {
insert = insert.concat('Buzz')
answer[i] = insert
continue
}

else {
answer[i] = number
}

}



Expand Down

0 comments on commit 7acef32

Please sign in to comment.