“Fizz Buzz -Programm in JavaScript” Code-Antworten

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

Fizz Buzz -Programm in 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

Ähnliche Antworten wie “Fizz Buzz -Programm in JavaScript”

Fragen ähnlich wie “Fizz Buzz -Programm in JavaScript”

Weitere verwandte Antworten zu “Fizz Buzz -Programm in JavaScript” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen