JavaScript Subtraction Comparison size operator practical application small case

Source: Internet
Author: User

<script src= "Jquery-1.9.1.min.js" ></script>
<script type= "Text/javascript" >

To compare the size of two numbers, the method encapsulates:
var i=4;
var j=5;
var rs=compare (I,J);
Console.info (RS);


2. The format definition of a method
/**
* Compare the size of 2 parameters
* @param first value
* @param the second value of second
*/
function Compare (first, second) {
if (First > second) {
return first;
} else {//First<=second
return second;
// }
// }

/**
* Addition operation
**/
var m=1;
var n=2;
var result=sum (m,n);
Console.info (Result)
//
function sum (m,n) {
var curresult=m+n;
return curresult;
//}
var a=2;
var b=3;
var rs=sum (A, b);
Console.info (RS);
function sum (first,second) {
return first+second;
// }

Division operation

function divID (first, second) {
return first/second;
// }
var c = 3;
var d = 6;
Console.info (divID (c, D));

Subtraction operations
var e=5;
var f=5;
var rs=minus (e,f);
Console.info (RS);
function minus (First,second) {
if (First>=second) {
return first-second;
}else{
return second-first;
}
}

/**
* Multiplication operation
**/
var g = 20;
var h = 3;
var rs = multi (g, h);
Alert (RS);
function multi (first,second) {
Return First*second
}
</script>

JavaScript Subtraction Comparison size operator practical application small case

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.