FizzBuzz Challenge


                    
        document.getElementById("btnFizzBuzz").addEventListener('click', function () {
            let fizz = Number(document.getElementById("btnFizzBuzz1").value); // usually 3
            let buzz = Number(document.getElementById("btnFizzBuzz2").value); // usually 5
            let output = DoFizzBuzz(fizz, buzz);
            //Step 3- Output the results of the FizzBuzz named function
            document.getElementById("FizzBuzzOut").innerHTML = output;
        });
        function DoFizzBuzz(fizz, buzz) {
            let output = "";
            for (let loop = 1; loop <= 100; loop++) {
            let fizzRemainder = loop % fizz;
            let buzzRemainder = loop % buzz;
                if (fizzRemainder == 0 && buzzRemainder == 0) {
                output += "FizzBuzz ";
                }
                else if (fizzRemainder == 0) {
                output += "Fizz ";
                }
                else if (buzzRemainder == 0) {
                output += "Buzz ";
                }
                else {
                output += `${loop} `;
                }
            }
            return output;
        };
        function ClearAll() {
            document.getElementById("btnFizzBuzz1").value = "";
            document.getElementById("btnFizzBuzz2").value = "";
            document.getElementById("FizzBuzzOut").value = "";
        };