Created
April 13, 2022 20:56
-
-
Save jcbombardelli/336f96887c49d07ef46378f76d249bb5 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
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