Created
October 20, 2023 23:18
-
-
Save marianozunino/bc0ac2e0125f8dde12641b9cb9d7da4f to your computer and use it in GitHub Desktop.
Calculadora
This file contains hidden or 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"); | |
| // 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