/**
* Exercise:
*
* Functional FizzBuzz
*
* Work in the console, or use "console.log()" to output to the console
* from the script
*
* Create a function that:
* - Accepts a single number argument
* - Returns the proper FizzBuzz result for that number
* Use this function to loop through 1…100 as before, but using your
* function to output the proper values to the console
*/
//var num = prompt("Please provide a number : ");
for(var i = 0;i <= 100; i++)
{
fb(i);
}
//fb(num);
function fb(numArg)
{
if(numArg % 3 == 0 && numArg % 5 ==0 )
{
console.log(numArg + "FizzBuzz");
}
else if(numArg % 3 == 0)
{
console.log(numArg + "Fizz");
}
else if(numArg % 5 ==0)
{
console.log(numArg + "Buzz");
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.