Exercise – Functional FizzBuzz

by Colin Cheevers

JavaScript

/**
 * 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");
    }
}