Skip to content

Instantly share code, notes, and snippets.

@gaspaonrocks
Created March 14, 2017 15:25
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 gaspaonrocks/0e15e16bd59c3c29c86fe38ff63c4b18 to your computer and use it in GitHub Desktop.
Save gaspaonrocks/0e15e16bd59c3c29c86fe38ff63c4b18 to your computer and use it in GitHub Desktop.
process.stdin.resume()
process.stdin.setEncoding('utf8')
function isANumber(age){
return !isNaN(age);
}
console.log('Hello ! What\'s your age ? ')
process.stdin.on('data', (age) => {
if (isANumber(age) === true && age <= 99) {
var birthYear = 2017 - age;
console.log('You were born in ' + birthYear);
} else {
console.log('that\'s not a number fella...');
}
process.exit()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment