Advertisement
Spocoman

06. Speed Info

Dec 10th, 2021 (edited)
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function speedInfo(input) {
  2.     let speed = Number(input[0]);
  3.     if (speed <= 10) {
  4.         console.log("slow");
  5.     }
  6.     else if (speed <= 50) {
  7.         console.log("average");
  8.     }
  9.     else if (speed <= 150) {
  10.         console.log("fast");
  11.     }
  12.     else if (speed <= 1000) {
  13.         console.log("ultra fast");
  14.     }
  15.     else {
  16.         console.log("extremely fast");
  17.     }
  18. }
  19.  
  20. РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
  21.  
  22. function speedInfo(input) {
  23.     let speed = Number(input[0]);
  24.  
  25.     console.log(speed <= 10 ? "slow" :
  26.                 speed <= 50 ? "average" :
  27.                 speed <= 150 ? "fast" :
  28.                 speed <= 1000 ? "ultra fast" : "extremely fast");
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement