January 21st, 2013, 06:11 PM
Conditional operator help
I am having a tough time understanding this "simple" conditional:
When variable row equals to 3 and no matter what value variable i is then the if statement is not true.
The way I understand this I should get alert('row is not 3 and i is not 9 ') ONLY id row is 3 and variable i is nine.
January 21st, 2013, 06:32 PM
No*: for the first branch to execute both "row is not 3" and "i is not 9" have to be true. The other branch will execute in the opposite case, namely if "row is not 3" is false or if "i is not 9" is false.
Once you've gotten a handle on that you can start simplifying the logic. Like getting rid of all those "is not"s in favor of just "is"s.
If "row is 3" then "row is not 3" is false and the second branch will execute.
* Everything else you said was right so I think that you typoed the "the way I understand this" statement.
Last edited by requinix; January 21st, 2013 at 06:35 PM.
January 22nd, 2013, 09:49 AM