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>
m'm
</body>
</html>
!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>if练习3</title>
<script type="text/javascript">
/*
* 编写程序,由键盘输入三个整数分别存入变量num1、num2、num3,
* 对他们进行排序,并且从小到大输出。
*/
var num1 = +prompt("请输入整数:");
var num2 = +prompt("请输入整数:");
var num3 = +prompt("请输入整数:");
</script>
</head>
<body>
</body>
</html>
网友评论