我们来学习一下用Visual Studio 2019软件,写if循环和判断,什么都不想说了,直接看代码得了,直接摆烂,自己看就行了,看不懂就算了。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// if嵌套 if结构含有其他if结构
/*
初级前端工程师
工作年限1以内 10000
工作年限2以内 15000
工作年限3以内 18000
中级前端工程师 工作年限4-5年 25000
高级前端工程师 工作年限5年以上 30000
*/
// 根据用户的级别和年限 给出对应的工资
var level = prompt("请输入您的级别");
if(level != "初级" && level != "中级" && level != "高级"){
alert("请输入正确的级别信息!")
}
if(level == "初级"){
var time1 = prompt("请输入您的年限")
if(time1 <= 1){
alert("薪资为10000");
}else if(time1 <= 2){
alert("薪资为1500");
}else if(time1 <= 3){
alert("薪资为18000");
}else{
alert("请输入正确的年限信息");
}
}
if(level == "中级"){
var time2 = prompt("请输入您的年限")
if(time2 > 3 && time2 < 6){
alert("薪资为25000");
}else{
alert("请输入正确的年限信息");
}
}
if(level == "高级"){
var time3 = prompt("请输入您的年限")
if(time3 > 5){
alert("薪资为30000");
}else{
alert("请输入正确的年限信息");
}
}
</script>
</body>
</html>
这是一个薪资的判断。