if/switch
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>奖励</title>
<script type="text/javascript">
var score = +prompt('请输入小茗同学的期末成绩(0-100):')
if(score == 100){
alert('BMW');
}
else if(score >= 80 && score <= 99){
alert('iphone20');
}
else if(score >= 60 && score < 80){
alert('参考书');
}
else{
alert('毛都没有');
}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>嫁不嫁</title>
<script type="text/javascript">
var height = +prompt('输入身高');
var fu = +prompt('输入身价');
var yanzhi = +prompt('输入颜值');
if (height>180 && fu>1000 && yanzhi >500){
alert('一定嫁他');
}else if (height>180 || fu>1000 || yanzhi >500){
alert('嫁吧,比上不足比下有余');
}else{
alert('不嫁');
}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>排序</title>
<script type="text/javascript">
var num1 = +prompt('输入数值:');
var num2 = +prompt('再输入数值:');
var num3 = +prompt('再再输入数值:');
if(num1>num2 && num1>num3 ){
if(num2>num3){
alert(num1+','+num2+','+num3);
}
else{
alert(num1+','+num3+','+num2);
}
}else if(num2>num1 && num2>num3 ){
if(num1>num3){
alert(num2+','+num1+','+num3);
}
else{
alert(num2+','+num3+','+num1);
}
}else if(num3>num2 && num3>num1 ){
if(num1>num2){
alert(num3+','+num1+','+num2);
}
else{
alert(num3+','+num2+','+num1);
}
}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>合格</title>
<script type="text/javascript">
var score = +prompt('输入分数:')
if(score > 60){
alert('合格');
}else{
alert('不合格');
}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>合格</title>
<script type="text/javascript">
var score = +prompt('输入分数');
switch(parseInt(score/10)){
case 10:
case 9:
case 8:
case 7:
case 6:
alert('合格');
break;
default:
alert('不合格');
break;
}
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>1~7</title>
<script type="text/javascript">
var week = +prompt('输入整数:');
switch(today){
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>