Skip to content

Instantly share code, notes, and snippets.

@angelique-w
Created October 4, 2019 14:12
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 angelique-w/9d36d06a617a01004cc4fc27b57ee4b1 to your computer and use it in GitHub Desktop.
Save angelique-w/9d36d06a617a01004cc4fc27b57ee4b1 to your computer and use it in GitHub Desktop.
process.stdin.resume()
process.stdin.setEncoding('utf8')
console.log('What\'s your age ? ')
process.stdin.on('data', age => {
const today = new Date();
const yearofBirth = today.getFullYear() - age;
console.log(((Number(age)) && (age <= 99) && (age < today)) ? `You were born in ${yearofBirth}` : 'The entry is incorrect')
process.exit()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment