“Program Buzz Fizz di JavaScript” 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

Program Buzz Fizz di JavaScript

//Fizz buzz
/* Divisible by 3 = fizz*/
/* Divisible by 5 = buzz*/
/* Divisible by both = fizzBuzz*/
// range 100

for(let numberRange = 1; numberRange <= 100; numberRange++){
    if(numberRange % 3 === 0 && numberRange % 5 === 0) {
        console.log('fizzBuzz');
    }else if(numberRange % 3 === 0){
        console.log('fizz');
    }else if(numberRange % 5 === 0){
        console.log('buzz')
        ;
    }else {
        console.log(numberRange);
    }
}
Water bottle

Jawaban yang mirip dengan “Program Buzz Fizz di JavaScript”

Pertanyaan yang mirip dengan “Program Buzz Fizz di JavaScript”

Lebih banyak jawaban terkait untuk “Program Buzz Fizz di JavaScript” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya