wth is undefined. Twey's code is right, except for negative values of y. This would fit the desired outcome stated by the OP about as well as can be divined:
Code:
var y = 15,
x = Math.max(0, y) && 240;
I'm trying to have var x equal zero if var y equals 0.
if var y is greater than 0 than war x will equal 240
It is left to the imagination what should happen if y is less than zero, but the pseudo code seems to indicate that x should be zero in that case. But negative values of y may be impossible, or the desired outcome for x in such a case may still be 240. If either of those cases are true, Twey's elegantly simple code is all that's required.
However, it's possible that yet another outcome is wanted for negative y.
Bookmarks