A slight issue with a project

function numberOfSupports (shipLvl){

    shipLvl = parseInt(shipLvl);

    let num = shipLvl-1;

    console.log(shipLvl);

    console.log("working3")

    if(shiplvl >= 2) {

        console.log("working4")

        for(let x= 0; num==x; x++) {

            var values = ["emp", "teleport", "red-Star-Extender", "remote-Repair", "time-Warp", "unity", "santuary", "stealth", "fortify", "impulse", "alpha-Rocket", "salvage", "suppress", "destiny", "barrier", "vengence", "delta-Rocket", "leap", "bond", "alpha-Drone", "suspend", "omega-Rocket", "remote-Bomb"];

            console.log("working5")

            var select = document.createElement("select");

            select.name = `support ${x}`;

            select.id = `support ${x}`;

            console.log(select.id, select.name)

            

            for (const val of values) {

                var option = document.createElement("option");

                option.value = val;

                option.text = val.charAt(0).toUpperCase() + val.slice(1);

                select.appendChild(option);

            }

            

        }

    }

}

So I’m having an issue with an if statement not working and I was hoping that someone could help me. This code is meant to create a number of drop down selection inputs so I can collect the value of the support units a player wants. But for whatever reason, its not getting by the if statement. I’ve tested it dozens of times trying to figure out why its not working, but for the life of me, I can’t find the issue.

Also, the last curly bracket is not matching with the code but with the text of this forum. No clue as to why.

the loop will execute only if the condition is true, maybe you need to check there

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Thanks, I’ll keep that in mind the next time I write a post.

No, I know its not this loop…well, not yet at least. If you’ll notice the console.log(“working4”); , it doesn’t trip that like its suppose to. Its how I know the if statement isn’t working.

I found the issue, that’s for the help. :slight_smile:

you have not given enough code to be able to test it

though check the loop condition too