odin-js-fundamentals-part-5/08_calculator/calculator.js

40 lines
598 B
JavaScript
Raw Normal View History

2024-01-11 08:56:09 +00:00
const add = function(a, b) {
return a + b;
2024-01-11 08:52:05 +00:00
};
const subtract = function(a, b) {
return a - b;
2024-01-11 08:52:05 +00:00
};
const sum = function(array) {
const output = array.reduce((total, value) => {
return total + value;
}, 0);
return output;
2024-01-11 08:52:05 +00:00
};
const multiply = function(array) {
const output = array.reduce((multiplification, value) => {
return multiplification * value;
}, 1);
return output;
2024-01-11 08:52:05 +00:00
};
const power = function(a, x) {
return 4 ** 3;
2024-01-11 08:52:05 +00:00
};
const factorial = function() {
};
// Do not edit below this line
module.exports = {
add,
subtract,
sum,
multiply,
power,
factorial
};