Build a command-line calculator that takes two numbers and an operator, then returns the result. Test all operations: +, -, *, /, %.
function calculator(a, b, op) {
switch (op) {
case '+': return a + b;
case '-': return a - b;
case '*': return a * b;
case '/': return b !== 0 ? a / b : 'Error: division by zero';
// ...Build a command-line calculator that takes two numbers and an operator, then returns the result. Test all operations: +, -, *, /, %.
function calculator(a, b, op) {
switch (op) {
case '+': return a + b;
case '-': return a - b;
case '*': return a * b;
case '/': return b !== 0 ? a / b : 'Error: division by zero';
// ...