Skip to content

Instantly share code, notes, and snippets.

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 sdesalas/1d5ebf6773e6550c2525030c3dfefe27 to your computer and use it in GitHub Desktop.
Save sdesalas/1d5ebf6773e6550c2525030c3dfefe27 to your computer and use it in GitHub Desktop.
NodeJS
process.stdin.resume()
process.stdin.setEncoding('utf8')
console.log('How old are you ? ')
process.stdin.on('data', (age) => {
console.log('You are ' + age.trim() + ' years old ')
if (age > 99){
console.log('Too old!!')
} else if (age < 0) {
console.log('You are from the future!');
} else if (!Number(age)) {
console.log('Please enter a number for your age');
} else {
var birth = 2019 - age;
console.log('You were born in ' + birth)
process.exit()
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment