Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

buzz fizz javascript

// 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()
Comment

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

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;
}
Comment

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

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"));
Comment

PREVIOUS NEXT
Code Example
Javascript :: export component react 
Javascript :: change on select with javascript 
Javascript :: how to setup icomoon in react js 
Javascript :: create object from array 
Javascript :: .fetch method 
Javascript :: 1 dollar in rupees 
Javascript :: is vowel javascript 
Javascript :: process return value 
Javascript :: window resize done 
Javascript :: axios response.json 
Javascript :: how to use empty href link in reactjs 
Javascript :: findone mongoose 
Javascript :: use font awsome in react 
Javascript :: javascript closure 
Javascript :: children javascript 
Javascript :: get key for value javascript 
Javascript :: react got error need to enable javascript 
Javascript :: vitejs env 
Javascript :: javascript array slice 
Javascript :: node-schedule npm 
Javascript :: React-redux and redux 
Javascript :: array flat 
Javascript :: javascript move array element to front 
Javascript :: how to change list item text color in react 
Javascript :: dynamic button click in javascript 
Javascript :: react native data map is not a function 
Javascript :: how to disable button in jquery 
Javascript :: vue displaying a this.length 
Javascript :: how to remove item from array javascript 
Javascript :: svg to png base64 javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =