forked from techswitch-learners/fizzbuzz-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fizzbuzz.js
29 lines (24 loc) · 947 Bytes
/
fizzbuzz.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Here, we create our main function.
function fizzbuzz() {
console.log('Welcome to FizzBuzz!');
for (let i = 1; i <= 10000; i++) {
let result = "";
if (i % 3 === 0) result = "Fizz";
if (i % 13 === 0) result += "Fezz";
if (i % 5 === 0) result += "Buzz";
if (i % 7 === 0) result += "Bang";
if (i % 11 === 0)
if (result === "Fezz") result += "Bong";
else result = "Bong";
if (i % 17 == 0) {
if (result.length === 12) {
result = `${result.substring(result.length, result.length-4)}${result.substring(4, 8)}${result.substring(0, 4)}`;
} else {
result = `${result.substring(result.length, result.length-4)}${result.substring(0, 4)}`;
}
}
result == "" ? console.log(i) : console.log(result);
}
}
// Now we run the main function...
fizzbuzz();