topical media & game development

talk show tell print

basic-javascript-02-ch2-examp7.htm / htm



  <html>
  <body>
  
  <script language="JavaScript" type="text/javascript">
  
  var myString = "56.02 degrees centigrade";
  var myInt;
  var myFloat;
  
  document.write("\"" + myString + "\" is " + parseInt(myString) + 
     " as an integer" + "<BR>");
  
  myInt = parseInt(myString);
  document.write("\"" + myString + "\" when converted to an integer equals " +
     myInt + "<BR>");
  
  myFloat = parseFloat(myString);
  document.write("\"" + myString +
     "\" when converted to a floating point number equals " + myFloat);
  
  </script>
  
  </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.