Skip to content

Instantly share code, notes, and snippets.

@ChandraNalaani
Created October 3, 2012 20:33
Show Gist options
  • Save ChandraNalaani/3829683 to your computer and use it in GitHub Desktop.
Save ChandraNalaani/3829683 to your computer and use it in GitHub Desktop.
Drink More Water (javascript)
// a node.js command line program
var rl = require('readline');
// requires node's readline module
var prompts = rl.createInterface(process.stdin, process.stdout);
prompts.question("How many 8oz glasses of water have you had today? ", function (glasses) {
var message = '';
if (glasses < 8) {
message = glasses + " glasses of water isn't enough. You need at least 8 8oz glasses of water every day for your brain and body to function at its best. Drink at least " + (8 - glasses) + " more.";
} else {
message = "Excellent! Keep up the good work.";
}
console.log(message);
process.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment