SOURCE

console 命令行工具 X clear

                    
>
console
function writeDocument(variable){
    document.write(variable+"<br/>")
}

var globalVariable1 =0;
document.write(globalVariable1 + "<br/>")
document.write(globalVariable2 + "<br/>")
function test1(){
    var localVariable1= 2;
    document.write(globalVariable1 + "<br/>")
    document.write(localVariable1 + "<br/>")
}

var globalVariable2 =1;

function tset2(){
    var localVariable2 =3;
    //document.write(localVariable1 + "<br/>")
}
//document.write(localVariable2 + "<br/>")
document.write(globalVariable1 + "<br/>")

/*function welcomeMes(){
    alert("Welcome");
}
function add(left,right){
    return left+right;
}
document.write((add1,2)+3)*/

function isLeapYear(year){
    if(year%4==0&&year%100!=0){
        document.write(year+"年为闰年"+"<br/>");
    }
    else if(year%100==0&&year%400==0){
        document.write(year+"年为闰年"+"<br/>");
    }
    else{
        document.write(year+"年不是闰年"+"<br/>");
    }
}
isLeapYear(2020);
isLeapYear(2001);
isLeapYear(2000);

/*var j=2000;
if(j%4==0&&j%100!=0){
    document.write(j+"年为闰年"+"<br/>");
}
else if(j%100==0&&j%400==0){
    document.write(j+"年为闰年"+"<br/>");
}
else{
    document.write(j+"年不是闰年"+"<br/>");
}

var x=2001;
if(x%4==0&&x%100!=0){
    document.write(x+"年为闰年"+"<br/>");
}
else if(x%100==0&&x%400==0){
    document.write(x+"年为闰年"+"<br/>");
}
else{
    document.write(x+"年不是闰年"+"<br/>");
}*/

writeDocument("-----------------------------------");

function maxNum(x,y,z,m){
    var a=[x,y,z,m]
    var max=0;
    for(i=0;i<4;i++){
        if(a[i]>max){
            max=a[i];
        }
    }
    return max;
}
writeDocument(maxNum(35,40,65,11)+"为四个数中的最大值");

writeDocument("-----------------------------------");


function findMax(x,y,z,m,n){
    var b=[x,y,z,m,n];
    var max=0;
    for(j=0;j<5;j++){
        if(b[j]>max){
            max=b[j];
        }
    }
    return max;
}
function findMin(x,y,z,m,n){
    var b=[x,y,z,m,n];
    var min=99999999;
    for(c=0;c<5;c++){
        if(b[c]<min){
            min=b[c];
        }
    }
    return min;
}
writeDocument(findMax(55,66,22,11,33)+"为五个数中的最大值");
writeDocument(findMin(55,66,22,11,33)+"为五个数中的最小值");
<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8" />
<title>Javascript函数</title>

</head>
<body>
    

</body>
</html>