Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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 :: jquery element distance from top of window 
Javascript :: javascript convert int to float with 2 decimal places 
Javascript :: js rectangle collision 
Javascript :: build json object in java 
Javascript :: made clickable url in js 
Javascript :: javascript read input from terminal 
Javascript :: react native metro api level 30 
Javascript :: discord.js channel regex 
Javascript :: switch browser to fullscreen 
Javascript :: Peerjs WebRTC video screen becomes black if not on wifi 
Javascript :: how to get the data attached with an element in javascript 
Javascript :: date regex 
Javascript :: Could not find router reducer in state tree, it must be mounted under "router" 
Javascript :: javascript replace spaces with one space 
Javascript :: linebreak eslint 
Javascript :: pattern cpf js 
Javascript :: how to prepare key in object dyamically javascript 
Javascript :: nodejs btoa 
Javascript :: adonisjs livereload 
Javascript :: angular amber theme 
Javascript :: how to shuffle an array in js 
Javascript :: object get property with max value javascript 
Javascript :: regex for ip address javascript 
Javascript :: jquery get input type 
Javascript :: how to make a if loop happen one 
Javascript :: How to update url using backbone 
Javascript :: convert hsl to hex code javascript 
Javascript :: jquery get select option attribute 
Javascript :: Error: Node Sass version 5.0.0 is incompatible with ^4.0 
Javascript :: timer.tc elixir 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =