Skip to content

Commit

Permalink
Adding main operations
Browse files Browse the repository at this point in the history
Implement add/subtrc/multiply/divide. Also add function operate which takes 2 operand and operator and then call callback operation function
  • Loading branch information
nberzerkov committed Jul 30, 2023
1 parent b47b910 commit 381f8e8
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
let operator;
let firstOperand;
let secondOperand;

function add(a, b) {
return a + b;
}

function subtract(a, b) {
return a - b;
}

function multiply(a, b) {
return a * b;
}

function divide(a, b) {
return a / b;
}

function operate(operator, leftNum, rightNum) {
return operator(leftNum, rightNum);
}

console.log(operate(subtract, 5, 2));

0 comments on commit 381f8e8

Please sign in to comment.