34 lines
568 B
JavaScript
34 lines
568 B
JavaScript
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,
|
|
} |