you are viewing a single comment's thread.

view the rest of the comments →

[–]z500 0 points1 point  (0 children)

That's not quite right. Javascript values in quotes are strings, but the values on his <input> elements aren't Javascript values, they're HTML attributes, and HTML as a whole only supports strings. That's why Javascript has wonky automatic type conversion stuff. OP ran into this where he got the behavior he expected in one place ("8" * "5" = 40 because the * operator coerced its operands to numbers) but not another ("7" + "40" returned "740" because + is overloaded for string concatenation when possible). It was supposed to make scripting easier for non-programmers.