Javascript FizzBuzz Solution

FizzBuzz Challenge Javascript Solution


FizzBuzz

FizzBuzz Challenge

enter numbers for fizz and buzz
=fizz
=buzz


Source Code


HTML with Javascript


<!DOCTYPE html>
<html>
    <head>
        <title>FizzBuzz</title>
    </head>
    <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>
        <script>
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>"); } } }
        </script>
    </body>
</html>

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






Comments

Popular posts from this blog

Crypto Mining

Multi-tap Keypad Text Entry