Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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);
  }
}
 
PREVIOUS NEXT
Tagged: #fizzbuzz #js
ADD COMMENT
Topic
Name
7+3 =