JavaScript-Writing arithmetic functions

Source: Internet
Author: User

Arithmetic function
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" ><html>  <head>    <title>Test03.html</title>    <script type="Text/javascript">        //var num1=prompt ("Please enter the first integer:", "");        //alert (typeof (NUM1));        //num1=parseint (NUM1);        //alert (typeof (NUM1));        //var num2=prompt ("Please enter a second decimal number:", "");        //num2=parsefloat (num2);        //var sum=num1+num2;        //alert ("Sum of two numbers:" +sum);        //nan represents non-numeric        //alert (parseint ("123abc456"));        //alert (typeof (NaN));        //alert (IsNaN ("Tom"));        //alert (IsNaN (")");        //no parameter function         function show(){             for(varI=0;i<5; i++) {Document.writeln ("Hello World!<br/>"); }        }//define a function with parameters         function show(count){             for(varI=0;i<5; i++) {Document.writeln ("Hello World!<br/>"); }        }//function with parameter return value         function calcsum(num1,num2){            returnnum1+num2; } function showsum(){            varNum1=prompt ("Please enter the first number:","");varNum2=prompt ("Please enter a second number:",""); num1=parsefloat(NUM1); Num2=parsefloat(NUM2);varSum=calcsum (NUM1,NUM2); Alert"The sum of two counts is:"+sum); }//Practice--Write a arithmetic function         function getusername(){Alert (document.getElementById ("username"). value); }</script>  </head>  <body>    <input type="button" value="show the specified number of times Hello World" onclick ="Show (Prompt (' Please enter the number of times ', ')") " /><br/>    <input type="button" value="Sum of two counts" onclick ="Showsum ()" /><br/>    <input type="button" value="Can not pass parameter when calling the parameter" onclick= "Show ()" /><br/>User name:<input type="text" id="username" /><input type="button" value="Get user name" onclick=" GetUserName () " />  </body></html>

JavaScript-Writing arithmetic functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.