var globalVarlablel = 0;
//打印localVarlabel
//document.write(localVarlable1);
//打印globalVarlabe2
//document.write(globalVarlale2);
function test1(){
var localVarlable1= 0;
//打印globalVarlabel
//document.write(globalVarlable1);
//打印localVarlabel
//document.write(localVarlable1);
}
test1();
var globalVarlable2 = 1;
function test2(){
var localVarlable2 = 1;
//打印localVarlabel
//document.write(localVarlablel);
}
test2();
//打印localVarlable2
//document.write(localVarlable2);
//打印globalVarlabel
//document.write(globalVarlabel);
function add(a,b){
return a+b;
}
document.write(add(2,6)+"<br/>");
function isLeapYear(year) {
//判断是否是闰年
if(year%4==0||year%100==0){
document.write(year+"年是闰年"+"<br/>");
}else{
document.write(year+"年不是闰年"+"<br/>");
}
}
//打印2020,2000,2001是否是闰年 能被4整除不能被100整除的是闰年 能被400整除是闰年
isLeapYear(2020);
isLeapYear(2000);
isLeapYear(2001);
//求出4个数中的最大值很简单,定义一个变量,然后每次比较两个数后,较大的数赋值给变量就可以
function max(a,b,c,d)
{
var max=0;
if(a>b)
{
max=a;
}else{
max=b;
}
if(max>c)
{
var max=max;
}else{
max=c;
}
if(max>d)
{
var max=max;
}else{
max=d;
}
document.write("最大值是"+max+"<br/>");
}
max(4,5,6,9)
console