Skip to content

Commit

Permalink
implemented simple operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Clara Tersi authored and Clara Tersi committed Jul 24, 2019
1 parent 1183611 commit af0ff83
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/operations/add.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const add = (addend1, addend2) => {
return addend1 + addend2;
};

module.exports = add;
8 changes: 8 additions & 0 deletions src/operations/divide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const divide = (dividend, divisor) => {
if (divisor === 0) {
throw new Error('Cannot divide by 0');
}
return dividend / divisor;
};

module.exports = divide;
11 changes: 11 additions & 0 deletions src/operations/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const add = require('./add');
const divide = require('./divide');
const multiply = require('./multiply');
const subtract = require('./subtract');

module.exports = {
add,
divide,
multiply,
subtract,
};
5 changes: 5 additions & 0 deletions src/operations/multiply.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const multiply = (multiplicand, multiplier) => {
return multiplicand * multiplier;
};

module.exports = multiply;
5 changes: 5 additions & 0 deletions src/operations/subtract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const subtract = (minuend, subtrahend) => {
return minuend - subtrahend;
};

module.exports = subtract;

0 comments on commit af0ff83

Please sign in to comment.