Skip to content

Instantly share code, notes, and snippets.

@sdesalas
Forked from evadav/quest.js
Last active April 4, 2019 13: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 sdesalas/cef022a7677410017b831f8d268e321d to your computer and use it in GitHub Desktop.
Save sdesalas/cef022a7677410017b831f8d268e321d to your computer and use it in GitHub Desktop.
My first application Node.JS
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