Skip to content

Instantly share code, notes, and snippets.

@marianozunino
Created October 20, 2023 23:18
Show Gist options
  • Select an option

  • Save marianozunino/bc0ac2e0125f8dde12641b9cb9d7da4f to your computer and use it in GitHub Desktop.

Select an option

Save marianozunino/bc0ac2e0125f8dde12641b9cb9d7da4f to your computer and use it in GitHub Desktop.
Calculadora
const readline = require("readline");
// TODO: que es stdin y stdout?
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
function add(a, b) {
return a + b;
}
function readNumber() {
// TODO: como cambio esto para que funcione como async/away?
// Excelente oportunidad para aprender sobre callback->promises->async/await
rl.question("Enter a number: ", (number) => {});
}
function calc() {
const a = readNumber();
const b = readNumber();
const result = add(a, b);
console.log(result)
}
calc();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment