Topic awaiting preservation: how do i calculate input values (Page 1 of 1) |
|
---|---|
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
posted 08-08-2002 19:27 |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 08-08-2002 19:45
you need to typecast them as numbers |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 08-08-2002 21:12
You might also want to try the parseInt and parseFloat functions, or you could call the .valueOf method of the strings, as so: |
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
posted 08-09-2002 11:53
thank you very much, guys! |
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
posted 08-21-2002 11:10
just wanted to add that valueOf() doesnt really work correctly! |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 08-21-2002 17:38
Actually, now that I think about it, it shouldn't work correctly. So forget that one. |
Paranoid (IV) Inmate From: Santa Clara, CA, USA |
posted 08-21-2002 17:50
You know, I've done this w/out casting them as numbers...but as vars. I wonder why it worked for me. I did: code: var age = prompt("What is your age?", " ");
|
Nervous Wreck (II) Inmate From: |
posted 08-21-2002 23:56
Maybe bc the + operator is an arthimetic operator and a string operator, where as the * operator is just an arthimetic operator. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 08-22-2002 03:46
Exactly =) |
Paranoid (IV) Inmate From: Santa Clara, CA, USA |
posted 08-22-2002 17:05
Ah. Interesting to know for future reference. Thanks! |