CISC103, Fall 2006, JavaScript Example
This version is broken
- When pulling a numeric value out of an input element in a form, we should use
parseInt()
or parseFloat
()
- But here we didn't do it!
- See page variableExample.02.html for a corrected version that includes the call to
parseFloat()
- The data returned by the value attribute of the price object has the string data type.
- Therefore, all the other values get a string data type
- Therefore, when we do the + operator to add the
tax
and the purchasePrice
, we get string concatenation instead of addition.