if if-else

  1. var distance = prompt("请输入距离");
  2. if (distance > 0 && distance <= 400) {
  3. console.log("24家");
  4. } else if (distance > 400 && distance <= 1000) {
  5. console.log("30家");
  6. } else if (distance > 1000 && distance <= 3000) {
  7. console.log("40家");
  8. } else if (distance > 3000 && distance <= 5000) {
  9. console.log("100家");
  10. } else if (distance > 5000) {
  11. console.log("100+家");
  12. }
  1. var score = prompt("请输入你的高考分数");
  2. if (score < 480) {
  3. console.log("其他大学")
  4. }else if (score >= 480 && score < 540) {
  5. console.log("普通大学");
  6. } else if (score >= 540 && score < 630) {
  7. console.log("工程大学");
  8. } else if (score >= 630) {
  9. console.log("华科大学");
  10. }
  1. var working_years = prompt("请输入你的工龄");
  2. if (working_years < 1 && working_years >= 0) {
  3. console.log("3天年假");
  4. } else if (working_years >= 1 && working_years < 3) {
  5. console.log("5天年假");
  6. } else if (working_years >= 3) {
  7. console.log("15天年假");
  8. }