<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Mobile-Web-App: Javascript Exercise - number arithmetic, toFixed() and toPrecision()</title> <script> function test(){ var a = 10.1; var b = 10.2; var c = a + b; info = "<p>a = 10.1, b = 10.2, c = a + b</p>" + "<p> a + b = " + (a + b) + "</p>" + "<p> c = " + c + "</p>" + "<p> c.toFixed(2) = " + c.toFixed(2) + "</p>" + "<p> c.toPrecision(8) = " + c.toPrecision(8) + "</p>"; document.getElementById("prompt").innerHTML=info; } </script> </head> <body onload="test();"> <h1>Mobile-Web-App: Javascript Exercise - number arithmetic, toFixed() and toPrecision()</h1> <div id="prompt"></div> </body> </html>
Saturday, April 21, 2012
Javascript Exercise - number arithmetic, toFixed() and toPrecision()
Labels:
Fundamental.Javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment