![]() Topic awaiting preservation: how do i calculate input values (Page 1 of 1) |
|
---|---|
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
![]() |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
![]() you need to typecast them as numbers |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
![]() 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 |
![]() thank you very much, guys! |
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
![]() just wanted to add that valueOf() doesnt really work correctly! |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
![]() Actually, now that I think about it, it shouldn't work correctly. So forget that one. |
Paranoid (IV) Inmate From: Santa Clara, CA, USA |
![]() 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: |
![]() 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 |
![]() Exactly =) |
Paranoid (IV) Inmate From: Santa Clara, CA, USA |
![]() Ah. Interesting to know for future reference. Thanks! |