“JS Fizzbuzz” Kode Jawaban

Fizzbuzz JS

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);
  }
}
Fylls

Fizzbuzz JS

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);
  }
}
RohBot

Fizzbuzz Javascript

// This is the most compact one I could make

for (let i = 1; i < 101; i++) console.log((i % 3 ? "" : "fizz") + (i % 5 ? "" : "buzz"));
Coin Hunter

Fizzbuzz JS

for(let i=0;i<100;)console.log((++i%3?'':'fizz')+(i%5?'':'buzz')||i)
nev gon giv u up

JS Fizzbuzz

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;
}
Patrick Sullivan

Jawaban yang mirip dengan “JS Fizzbuzz”

Pertanyaan yang mirip dengan “JS Fizzbuzz”

Lebih banyak jawaban terkait untuk “JS Fizzbuzz” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya