For loops check your second declaration on each iteration. Force it to be false on the second iteration, and you've got something that'll check your condition a single time.
Referencing an index that that exists gives you the value stored there, but referencing an index that doesn't exist gives you undefined. Use an "or" statement to give yourself a fallback value when this happens, and you'll be ready to go.
You can purposefully throw exceptions when a boolean is false by referencing a variable that doesn't exist (the "throwException" variable in this case).
This is the same concept as for loops. Force the loop to stop after one iteration (this time with a break), and you've got something that'll check your condition a single time.
logical operators
The second half of an "and" statement only evaluates if the first half is true.
...
for loops
For loops check your second declaration on each iteration. Force it to be false on the second iteration, and you've got something that'll check your condition a single time.
...
arrays
Referencing an index that that exists gives you the value stored there, but referencing an index that doesn't exist gives you undefined. Use an "or" statement to give yourself a fallback value when this happens, and you'll be ready to go.
Or, fill an array with your options, and leverage the fact that true can be used as 1 in JavaScript to do some index-selection math.
...
try/catch blocks
You can purposefully throw exceptions when a boolean is false by referencing a variable that doesn't exist (the "throwException" variable in this case).
...
while loops
This is the same concept as for loops. Force the loop to stop after one iteration (this time with a break), and you've got something that'll check your condition a single time.
...
switch statements
Who could forget the classic alternative to if statements? Technically not even cheating!
Wow, those are some solutions right there! Thanks a lot for sharing and taking the time to explain it.
I did some silly stuff, just for fun lol: