ProdanTenev

Ages

Mar 21st, 2022
1,096
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 0.65 KB | None | 0 0
  1. function ages(age) {
  2.     // 0-2 (age) – is a baby;  
  3.     // 3-13 (age) – is a child;
  4.     // 14-19 (age) – is a teenager;
  5.     // 20-65 (age) – is an adult;
  6.     // >=66 (age) – is an elder;
  7.     // In all other cases print – "out of bounds";
  8.     if (age >= 0 && age <= 2) {
  9.         console.log("baby");
  10.     } else if (age >= 3 && age <= 13) {
  11.         console.log("child");
  12.     } else if (age >= 14 && age <= 19) {
  13.         console.log("teenager");
  14.     } else if (age >= 20 && age <= 65) {
  15.         console.log("adult");
  16.     } else if (age >= 66) {
  17.         console.log("elder");
  18.     } else {
  19.         console.log("out of bounds");
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment