Correcting teacher:西门大官人
Correction status:qualified
Teacher's comments:
<script>
var name = 'php中文网';
var site = 'www.php.cn';
function getName() {
console.log(name);
}
function getSite() {
console.log(site);
}
//调用方法
getName();
getSite();
</script>
<script>
// if
var stars = 100;
if (stars > 112) {
alert('最强王者');
}
if (stars <= 112 && stars > 87) {
alert('至尊星耀');
}
if (stars <= 87 && stars > 62) {
alert('永恒钻石');
}
if (stars <= 62 && stars > 37) {
alert('尊贵铂金');
}
if (stars <= 37) {
alert('都是小学生...');
}
// if...else...
var a = 200;
var b = 300;
if (a > b){
alert('a 大于 b');
}else {
alert('a 小于 b');
}
// switch...case...
var status = 2;
switch (status) {
case 0:
alert('已取消');
break;
case 1:
alert('已下单');
break;
case 2:
alert('已付款');
break;
case 3:
alert('已发货');
break;
case 4:
alert('已收货');
break;
case 5:
alert('已评论');
break;
}
</script>
<script>
// for循环
for (let i = 0; i < 10; i++) {
console.log(i);
}
// while循环
var i = 0;
while (i < 10) {
console.log(i);
i++;
}
// do...while循环
var num = 0;
do {
console.log(num);
num++;
}while (num < 20);
</script>
</script>
var age = '30';
console.log(parseInt(age)); //输出:30
if (isNaN(age)){
console.log('是数字');
}else {
console.log('非数值类型');
}
// 输出:非数值类型
</script>
THE END !