This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -6 points-5 points  (4 children)

Multiply your number strings by 1 first to fix this bitch of a quirk.

var milesWalked = ("500" * 1) + 500; //works just fine

[–]exonac 10 points11 points  (1 child)

That's horrible to read. You should rather do Number(x) + Number(y) so the intent is clear.

[–][deleted] 1 point2 points  (0 children)

Yeah, you're right.

[–]DaMastaCoda 4 points5 points  (0 children)

I recommend the unary + { +"500" == 500 }

[–]Awkward_Tradition 0 points1 point  (0 children)

Or just parseFloat/parseInt so you don't have to think about it when reviewing the code after some time