About the Project

A typical example of the Fizz Buzz project would be to write a program that prints the numbers 1 to 100, but for multiples of 3 and 5 (i.e. 15 and 45) the program prints out the word 'FizzBuzz', for multiples of 3 only the program prints out the word 'Fizz', and for multiples of 5 the program prints out the word 'Buzz'. Otherwise, the program will just print out the next number.

fizz buzz drink

Try it out

Enter a first and last number and press submit.

Numbers

Results

Check out my Code


$(document).ready(function () {

    $("#submitButton").click(function () {
        let emptyString = "";
        let firstNumber = parseInt($("#firstNumber").val());
        let lastNumber = parseInt($("#lastNumber").val());
        for (let i = firstNumber; i <= lastNumber; i++) {
            if (i % 5 == 0 && i % 3 == 0) {
                emptyString += "Fizz Buzz! \n";
            }
            else if (i % 5 == 0) {
                emptyString += "Fizz \n";
            }
            else if (i % 3 == 0) {
                emptyString += "Buzz \n";
            }
            else {
                emptyString += i + '\n';
            }
        }
        $("#resultText").val(emptyString);
    });
    $("#clearButton").on("click", function () {
        $("#firstNumber").val("");
        $("#lastNumber").val("");
        $("#resultText").val("");
        $("#firstNumber").focus();
    });


});
asp net logo coder foundry logo

Contact me

Do you have any questions? Please do not hesitate to contact me directly. I will respond to your email within a matter of hours to help you.