// Buzz fizz javascript
function fizzBuzz(){
for(let i=1; i<=100; i++){
if(i % 3 === 0 && i % 5){
console.log("fizzBuzz")
}
if else (i % 3 === 0){
console.log("fizz")
}else if(i % 5 === 0){
console.log("Buzz")
}else{
console.log(i)
}
}
}
fizzBuzz()
function fizzBuzz2(n) {
for (let i = 1; i <= n; i++) {
let str = "";
if (i % 3 === 0) str += "fizz"
if (i % 5 === 0) str += "buzz"
if (str === "") str = i;
console.log(str);
}
}
function fizzBuzz(num) {
if (num % 3 === 0 && num % 5 === 0) {
return 'FIZZBUZZ';
}
if (num % 3 === 0) {
return 'FIZZ';
}
if (num % 5 === 0) {
return 'BUZZ';
}
return num;
}
function fizzBuzz(n) {
for (let i = 1; i <= n; i++) {
let fizzbuzz = "";
if (i % 3 === 0)
fizzbuzz += "fizz"
if (i % 5 === 0)
fizzbuzz += "buzz"
if (fizzbuzz === "")
fizzbuzz = i;
console.log(fizzbuzz);
}
}
// This is the most compact one I could make
for (let i = 1; i < 101; i++) console.log((i % 3 ? "" : "fizz") + (i % 5 ? "" : "buzz"));