February 1, 201016 yr greetings, im just learning javascript, and have a question. script type="text/javascript"> var name=prompt("add this"); var name2=prompt("and add this"); alert(name+name2); </script> I have that script, and its concatenating the results together so 1+1=11 at the moment. I want it to equal 2, so 1+1=2 or 5+2=9. How would I do that? thank you. Reply With Quote
February 1, 201016 yr <script type="text/javascript"> var name=prompt("add this"); var name2=prompt("and add this"); alert(parseFloat(name)+parseFloat(name2)); </script>
February 1, 201016 yr Author <script type="text/javascript"> var name=prompt("add this"); var name2=prompt("and add this"); alert(parseFloat(name)+parseFloat(name2)); </script> Mucos gracias:).
Create an account or sign in to comment