2024-01-11 22:20:16 +00:00
|
|
|
function add(a, b) {
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
function substract(a, b) {
|
|
|
|
return a - b;
|
|
|
|
}
|
|
|
|
|
|
|
|
function multiply(a, b) {
|
|
|
|
return a * b;
|
|
|
|
}
|
|
|
|
|
|
|
|
function divide(a, b) {
|
|
|
|
return a / b;
|
|
|
|
}
|
|
|
|
|
|
|
|
function operate(equals) {
|
|
|
|
switch(equals.operator) {
|
|
|
|
case "+":
|
|
|
|
return add(equals.a, equals.b);
|
|
|
|
case "-":
|
|
|
|
return substract(equals.a, equals.b);
|
|
|
|
case "*":
|
|
|
|
return multiply(equals.a, equals.b);
|
|
|
|
case "/":
|
|
|
|
return divide(equals.a, equals.b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let operation = {
|
|
|
|
a: 0,
|
|
|
|
operator: "+",
|
|
|
|
b: 0,
|
|
|
|
}
|