This Fizz Buzz page shows my Javascript code

A Syntax Highlighter - Prism.js is used to show the code from the HTML page.

  • Code with highlighter
  • Will display on this page
            
                    function fizzBuzz() {

                    document.getElementById("button").addEventListener('click', () => {
                    let minInput = parseInt(document.getElementById("minInput").value);
                    let maxInput = parseInt(document.getElementById("maxInput").value);
                    let fizzInput = parseInt(document.getElementById("fizzInput").value);
                    let buzzInput = parseInt(document.getElementById("buzzInput").value);

                    let arrayModified = modifiedData(minInput, maxInput, fizzInput, buzzInput);

                    document.getElementById('printBox').innerHTML = arrayModified;
                    })

                    function modifiedData(minInput, maxInput, fizzInput, buzzInput) {
                    var arrayModified = "";
                    for (let i = minInput; i<= maxInput; i++) {
                    let fizzRemainder = i % fizzInput;
                    let buzzRemainder = i % buzzInput;

                    if (fizzRemainder == 0 && buzzRemainder == 0) {
                    arrayModified += "FIZZBUZZ! ";
                    } else if (fizzRemainder == 0) {
                    arrayModified += "fizz ";
                    } else if (buzzRemainder == 0) {
                    arrayModified += "buzz ";
                    } else {
                    arrayModified += i+' ';
                    }

                    }

                    return arrayModified;
                    }