-
-
Save sdesalas/cef022a7677410017b831f8d268e321d to your computer and use it in GitHub Desktop.
My first application Node.JS
This file contains hidden or 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') | |
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 < 1) { | |
console.log ('You have not been born yet') | |
} else if (!Number(age)) { | |
console.log ('That is not a valid age') | |
} else { | |
var year = 2019; | |
var birth = year - 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