Skip to content
Advertisement

Simple if statement returning unexpected value

So I have this simple if statement with an input from an array:

JavaScript

var_dump() returns:

JavaScript

Seems simple right?

Termijn is set to 2 in the array and the if statements set jaarlijks to selected well it doesn’t matter if I use 0, 1 or 2 as inputs it always sets jaarlijks to selected

Advertisement

Answer

Assuming this is still the code you are playing with, you will need to initialise your variables each time round the loop otherwise their values will remain from the previosu iteration of the loop.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement