Created
March 14, 2017 15:25
-
-
Save gaspaonrocks/0e15e16bd59c3c29c86fe38ff63c4b18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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