<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript">
var score=prompt('请输入小明的成绩')
if(score > 100 || score < 0 || isNaN(score)){
alert("玩什么玩写作业去");
}else{
//根据score的值来决定给小明什么奖励
if(score == 100){
//奖励一台宝马
alert("宝马拿去,随便开~~");
}else if(score >= 80){
//奖励一个手机
alert("手机拿去,随便玩~~");
}else if(score >= 60){
//奖励一本参考书
alert("书拿走,随便看~~");
}else{
alert("棍子一根~~");
}
}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>if练习</title>
<script type="text/javascript">
var height = prompt("请输入身高");
var money = prompt("请输入财富值");
var face = prompt("请输入颜值[百分之%]");
if (height>=180 && money>=10000 && face>=100){
alert("我一定嫁给他");
}
else if(height>=180 || money>=10000 || face>=100 ){
alert("嫁吧,比上不足,比下有余");
}
else{
alert("滚吧,不嫁");
}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript">
var num1 = +prompt("请输入第一个数:");
var num2 = +prompt("请输入第二个数:");
var num3 = +prompt("请输入第三个数:");
alert(typeof num1);
//找到三个数中最小的数
if(num1 < num2 && num1 < num3){
//num1最小,比较num2和num3
if(num2 < num3){
//num1 num2 num3
alert(num1 +","+num2 + ","+num3);
}else{
//num1 num3 num2
alert(num1 +","+num3 + ","+num2);
}
}else if(num2 < num1 && num2 < num3){
//num2最小,比较num1和num3
if(num1 < num3){
//num2 num1 num3
alert(num2 +","+num1 + ","+num3);
}else{
//num2 num3 num1
alert(num2 +","+num3 + ","+num1);
}
}else{
//num3最小,比较num1和num2
if(num1 < num2){
// num3 num1 num2
alert(num3 +","+num1 + ","+num2);
}else{
//num3 num2 num1
alert(num3 +","+num2 + ","+num1);
}
}
</script>
</head>
<body>
</body>
</html>
switch1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript">
var score =75;
switch(score){
case score >= 60 && score <=100:
alert("合格");
break;
case score < 60 && score >=0:
alert("不合格");
break;
default:
alert("不合法");
break;
}
</script>
</head>
<body>
</body>
</html>
switch2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>switch2</title>
<script type="text/javascript">
var date=7;
switch (date){
case 1:
alert("星期一");
break;
case 2:
alert("星期二");
break;
case 3:
alert("星期三");
break;
case 4:
alert("星期四");
break;
case 5:
alert("星期五");
break;
case 6:
alert("星期六");
break;
case 7:
alert("星期日");
break;
default:
alert("输入不合法");
break;
}
</script>
</head>
<body>
</body>
</html>
网友评论