Check Out the Code


 document.getElementById("btnFizz").addEventListener('click', function() {
    //Get user input
    let f = Number(document.getElementById("userIn1").value); //User inputs
    let b = Number(document.getElementById("userIn2").value);

    FizzBuzz(f, b);
})

//Named function
function FizzBuzz(f, b) {
    let output = "";
    let classCollect = document.getElementsByClassName("fizzy")

    for (let loop = 1; loop < classCollect.length; loop++) {
        let fizzRemainder = loop % f;
        let buzzRemainder = loop % b;


        if (fizzRemainder === 0 && buzzRemainder === 0) {

            classCollect[loop].innerHTML = "FizzBuzz!";
            classCollect[loop].style.fontWeight = "bold";
        }
         else if (fizzRemainder === 0) {

            classCollect[loop].innerHTML = "Fizz";
            classCollect[loop].style.fontWeight = "bold";

        }
        else if (buzzRemainder === 0) {

            classCollect[loop].innerHTML = "Buzz";
            classCollect[loop].style.fontWeight = "bold";

        }
        else {

            classCollect[loop].innerHTML = loop;
        }
    }
}