This isn't a javascript problem. They were trying to be too clever and test whether a value was set in the same statement where that value was used for a comparison.
The non-truthiness of 0 is something present in many languages.
The non-truthiness of 0 is something present in many languages.