Advertisement
Nikolay_Kashev

Ages

Apr 16th, 2024
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.75 KB | Source Code | 0 0
  1. 'use strict';
  2.  
  3. const readline = require('readline');
  4.  
  5. const rl = readline.createInterface({
  6.     input: process.stdin,
  7.     output: process.stdout
  8. });
  9.  
  10. function determineAgeGroup(age) {
  11.     if (age >= 0 && age <= 2) {
  12.         console.log("baby");
  13.     } else if (age >= 3 && age <= 13) {
  14.         console.log("child");
  15.     } else if (age >= 14 && age <= 19) {
  16.         console.log("teenager");
  17.     } else if (age >= 20 && age <= 65) {
  18.         console.log("adult");
  19.     } else if (age >= 66) {
  20.         console.log("elder");
  21.     } else {
  22.         console.log("out of bounds");
  23.     }
  24.    
  25.     rl.question('Press any key to continue...', () => {
  26.         rl.close();
  27.     });
  28. }
  29.  
  30. rl.question('', (age) => {
  31.     determineAgeGroup(parseInt(age));
  32. });
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement