samedi 21 juillet 2018

Why isn't this variable undefined?

I'm extremely new to JavaScript so my apologies if the answer is obvious but I am testing out a script and unfortunately I cannot figure out what is happening.

let taxableIncome = 1000;
let Income;
let y;

if(taxableIncome == 18201 || taxableIncome >18201 && taxableIncome 
<37001); {
 y = taxableIncome - 18200
Income = y - 0.19 * y + 18200
}

console.log(Income);

The console is logging the number as 4268 where it should be undefined because taxableIncome is only 1000 and therefore does not meet the if requirements so the code inside should not be run.

Any help would be appreciated :)

Aucun commentaire:

Enregistrer un commentaire