<HTML>

<HEAD>
<TITLE>Java Script input string and convert to integer and float</A></TITLE>
</HEAD>

<BODY>

<SCRIPT>
/*This script will input a float and then add the numbers*/



var sum = 0, howmany=0;
var numstring = null;//declaring and setting a string to the null string.


numstring = prompt ("Find the sum of the first what natural numbers?","");//inputting a string.
howmany = parseInt(numstring);





for (var i = 1; i <= numstring; i++)
{
  sum += i;
  
}


alert("The sum of the first " +howmany+ " natural numbers is " +sum);





</SCRIPT>
</BODY>
</HTML>

Run Script