Javascript FizzBuzz Solution

FizzBuzz Challenge Javascript Solution


FizzBuzz Challenge

enter numbers for fizz and buzz

Source Code

HTML with Javascript

<!DOCTYPE html>
    <body bgcolor="lightblue">
    <h1>FizzBuzz Challenge</h1>
    <p>enter numbers for fizz and buzz</p>
        <input id="x"></input>=fizz
        <input id="y"></input>=buzz<br>
        <button onclick="fb()">run</button>
function fb() {
        var a = document.getElementById("x").value;       
        var b = document.getElementById("y").value;

for(i=1; i<101; i++) {
if (i % a === 0 && i % b === 0){ document.write ("Fizz"+"Buzz<br>"); }
else if(i % a === 0) { document.write("Fizz"+"<br>"); }
else if(i % b === 0) { document.write("Buzz"+"<br>"); }
else { document.write(i+"<br>"); } } }

Click here to run this code on Sololearn

Click here to view FizzBuzz Challenge

I hope you enjoyed this content please consider supporting the development of Free Code Examples

Thank you and have a Blessed Day

Try these Fun Games by Bobbie:

Ocean Treasures Game

Travel Blast Game New York

Play and Learn Russian

Battlestarship Game

Take a look at these Groovy Codes:

Fun IQ Test

Html Svg Starburst

Javascript Particles Fishes

Read the Latest Breaking Programming and Tech News, Great Articles and Tips:

Codenewz Programming and Tech News


Popular posts from this blog

Multi-tap Keypad Text Entry

HTML5 Crossword 1