Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jcbombardelli/336f96887c49d07ef46378f76d249bb5 to your computer and use it in GitHub Desktop.
Save jcbombardelli/336f96887c49d07ef46378f76d249bb5 to your computer and use it in GitHub Desktop.
const readline = require("readline-sync");
function main() {
clear();
let op;
do {
op = readline.questionInt(
"1. Add a new block\n2. Print the chain\n0. Exit\n"
);
clear();
switch (op) {
case 1:
const amount = readline.questionInt("Amount: ");
const message = readline.question("Message: ");
console.log("Block added!");
clear(true);
break;
case 2:
clear(true);
break;
case 0:
console.info("Bye!");
break;
default:
console.error("Invalid option");
clear();
break;
}
} while (op !== 0);
}
function clear(pressAnyKey) {
if (pressAnyKey) readline.keyIn("Press any key to continue...");
console.clear();
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment