<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>if练习</title>
</head>
<script type="text/javascript">
var score = prompt('请输入小明的期末成绩:');
if(score>=60 && score<=79){
alert('奖励一本参考书');
}
else if(score>=80 && score<=99){
alert('奖励一台iPhone XS');
}
else if(score==100){
alert('奖励一台BMW X6');
}
else{
alert('奖励一个大嘴巴子');
}
</script>
<body>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>if练习2</title>
</head>
<script type="text/javascript">
var money = prompt('请输入身价:');
var yan = prompt("请输入颜值:");
var leng = prompt('请输入身高:');
if(money>=10000000 && yan>=500 && leng>=180){
alert('我要嫁给他');
}
else if(money>=1000000 && yan>=50 && leng>=170){
alert('比上不足比下有余');
}
else{
alert('不嫁');
}
</script>
<body>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<script type="text/javascript">
var num1 = +prompt("请输入第一个数:");
var num2 = +prompt("请输入第二个数:");
var num3 = +prompt("请输入第三个数:");
//找到三个数中最小的数
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>
<body>
</body>
</html>
网友评论