sandbox-js/calculator.js
2023-01-23 15:50:31 -05:00

23 lines
368 B
JavaScript

const prompt = require("prompt-sync")({sigint: true});
function add(a, b) {
let e = a + b;
return e;
}
let c = prompt("Num 1: ");
let d = prompt("Num2: ");
let op = prompt("What operation? ");
if (op == "+") {
console.log(Number(c) + Number(d));
}
if (op == "-") {
console.log(Number(c) - Number(d));
}
if (op == "*") {
console.log(Number(c) * Number(d));
}