FizzBuzz Solution: JavaScript


  • 0
    R
    var fizzBuzz = function(n) {
        for (var i=1; i<16; i++){
            if(i%3==0 && i%5==0)
                console.log("FizzBuzz");
            else if (i%3==0)
                console.log("Fizz");
            else if (i%5==0)
                console.log("Buzz");
            else 
                console.log(i) 
            }
    }
    
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.