samedi 1 septembre 2018

Hey everyone! I've been struggling to figure out this if-else statement

I am trying to have a modal pop up with my output in the body, and if the input is left blank then a sweet alert pops up. I don't currently have the if-else statement set up for that because I have tried everything and it won't work.

    $("#btnfb").click(function () {
        var numfiz = $("#fizz").val();
        var numbuz = $("#buzz").val();
        var outputarray = []; 
        for (var loop = 1; loop <= 100; loop++) {
            if (loop % numfiz === 0 & loop % numbuz === 0) {
                outputarray.push("<span 
                class='boldItalicPurple'>Fizzbuzz</span>");
            }
            else if (loop % numfiz === 0) {
                outputarray.push("<span 
                class='boldItalicGreen'>Fizz</span>");
            }
            else if (loop % numbuz === 0) {
                outputarray.push("<span 
                class='boldItalicOrange'>Buzz</span>");
            }
            else {
                outputarray.push(loop);
            }
        }
        $("fzbzout").html(outputarray.join(", "));
        $('#myModal5').modal('show');
    });

Aucun commentaire:

Enregistrer un commentaire