Correcting teacher:西门大官人
Correction status:qualified
Teacher's comments:案例中do while前把i初始化一下:i=0;否则i会从10开始循环
<script type="text/javascript">
// 定义一个函数
function afun(){
document.write('这是一个函数');
}
afun();
// 定义变量
var a,b,sum;
a= 1;
b =2;
sum =a +b;
console.log(sum);
</script>
<script type="text/javascript">
var grade = 89;
if(grade>90){
console.log('成绩优秀继续保持');
}else{
console.log('继续努力');
}
if(grade>90){
console.log('成绩游戏继续保持');
}else if(60<=grade<=90){
console.log('成绩不错继续努力');
}else{
console.log('成绩不合格,加油');
}
var x = 1;
switch(x){
case 0:
console.log('off');
break;
case 1:
console.log('ON');
break;
default:
console.log('no value found');
}
switch (new Date().getDay()){
case 5:
console.log('周末快到了');
break;
case 0:
case 6:
console.log('今天是周末');
break;
default:
console.log('期待周末');
}
</script>
<script type="text/javascript">
var i= 1;
// while循环
while(i<10){
i++;
}
console.log(i);
// do while循环
do{
i++;
}while(i<11)
console.log(i);
// for循环
for(var i=1;i<20;i++){
}
console.log(i);
</script>
<script type="text/javascript">
// parseInt函数练习
var num1 =parseInt('12345red');
document.write(num1+'<br>');
var num1 = parseInt('0xa');
document.write(num1+"<br>");
var num1 = parseInt("56.9");
document.write(num1+'<br>');
var num1 = parseInt('r23');
document.write(num1+'<br>');
// isNaN函数练习
document.write(isNaN(123)+"<br />");
document.write(isNaN(-1.23)+"<br />");
document.write(isNaN(5-2)+"<br />");
document.write(isNaN(0)+"<br />");
document.write(isNaN('HELLO')+"<br />");
document.write(isNaN('2005/12/12')+ "<br />");
</script>