samedi 30 mars 2019

If conditions are never satisfied (even though they are)

I wrote an if statement followed by an else statement. Now even if the conditions are satisfied, it will just go to the else statement.

I've tried using Objects.equal() but that's not really what I want since I'm using >= signs instead of == signs, it also gives me errors and basically the whole program doesn't work. I also tried putting all conditions to the default values so I can be sure that they are satisfied but still nothing.

This is the function that contains the if statement.

function evolve() {
            if (coins >= 1000000000 && timesbuyj1 >= 10 && timesbuyj2 >= 10 && timesbuyj3 >= 10) {
                evolutions = evolutions += 1
                var coins = 0
                var timesbuyj1 = 0
                var price01cs = 15
                var timesbuyj2 = 0
                var price1cs = 100
                var timesbuyj3 = 0
                var price8cs = 1100
                var timesbuyj4 = 0
                // a bunch of lines of code that doesn't concern this here //
                }
            } else {
                alert("You don't meet the requirements.")
            }
        } 

When I change the values to satisfy the conditions, I expect everything to reset, change, etc.. But it just gives tells me You don't meet the requirements. and doesn't run the code it's supposed to run.

Aucun commentaire:

Enregistrer un commentaire