Skip to content

Commit e83bb3e

Browse files
authored
Create fizzbuzz.js
1 parent c5511ec commit e83bb3e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Interview-Questions/fizzbuzz.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function fizzBuzz(n) {
2+
for (let i = 1; i <= n; i++) {
3+
if (i % 3 === 0 && i % 5 === 0) {
4+
console.log("FizzBuzz");
5+
} else if (i % 3 === 0) {
6+
console.log("Fizz");
7+
} else if (i % 5 === 0) {
8+
console.log("Buzz");
9+
} else {
10+
console.log(i);
11+
}
12+
}
13+
}
14+
15+
function main() {
16+
const n = parseInt(readLine().trim(), 10);
17+
fizzBuzz(n);
18+
}

0 commit comments

Comments
 (0)