Skip to content

Instantly share code, notes, and snippets.

@ealipio
Last active November 23, 2019 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ealipio/ba72d94e20e26ed549a88f416854e112 to your computer and use it in GitHub Desktop.
Save ealipio/ba72d94e20e26ed549a88f416854e112 to your computer and use it in GitHub Desktop.
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
const printMessagetoUser = ({name, age}) => {
if (!isNaN(age)) {
const yearOf100 = new Date().getFullYear() + (100 - age);
if (age > 100) {
console.log( `Lo lamento ${name} tu ya cumpliste cien hace ${age - 100} anhios.`);
} else {
console.log(`Hola ${name}, en el ${yearOf100} tendras 100 anhios`);
}
} else {
console.log(`debes ingresar un numero parfavar`);
}
}
rl.question('Cual es tu nombre? ', name => {
rl.question('Cual es tu edad? ', age => {
printMessagetoUser({ name, age });
rl.close();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment