1, two number of the maximum value
function Getmax (A, b) {
if (a>b) {
return A;
}else{
return b;
}
}
var Max = Getmax (300,600)
Console.log (Max)
Minimum value of 2, two digits
function Getmin (A, b) {
if (a>b) {
return b;
}else{
return A;
}
Return a<b?a:b;
}
var Min = getmin (400,800)
Console.log (Min)
3, seek n-m between the and
function Getsum (n,m) {
var getsum = 0;
for (var i= n; i<=m; i++) {
getsum+= i;
}
return getsum;
}
var sum = getsum (1,10);
Console.log (SUM)
4. Calculate the area of the circle
function Getarea (r) {
var PI = 3.14;
Return Pi*r*r
}
var area = Getarea (10);
Console.log (area)
5, to seek the circumference of the circle
function Getarea (R) {
var PI = 3.14;
return 2*pi*r;
}
var area = Getarea (2)
Console.log (area)
6. Find the maximum value in three numbers
function Getmax (a,b,c) {
if (a>b && a>c) {
return A;
}else if (b>a && b>c) {
return b;
}else{
return C;
}
}
var Max = Getmax (23,34,45)
Console.log (Max)
function Getmax (a,b,c) {
var d = Math.max (A, b);
var e = Math.max (d,c);
return e;
}
var max = Getmax (100,390,500);
Console.log (max)
7, to find a group of the maximum value
var nums = [12,23,34,45,56,67,78,89,90];
var max = nums[0];
For (var i= 1; i< nums.length;i++) {
if (Max<nums[i]) {
max = Nums[i];
}
}
Console.log (max)
var nums = [12,23,34,45,56,67,78,89,90];
function Getmax (array) {
var max = array[0];
for (Var i=1;i<array.length;i++) {
if (max< Array[i]) {
max = Array[i];
}
}
return Max;
}
var max = Getmax (nums);
Console.log (max)
8. Find the minimum value of a group of numbers
var nums = [12,23,34,45,56,67,78,89,90];
function Getmin (array) {
var min = array[0];
for (Var i=1;i<array.length;i++) {
if (Min>array[i]) {
min = Array[i];
}
}
return min;
}
var min = getmin (nums);
Console.log (min)
About the function of exercise one