40 lines
580 B
JavaScript
40 lines
580 B
JavaScript
const add = function(a, b) {
|
|
return a + b;
|
|
};
|
|
|
|
const subtract = function(a, b) {
|
|
return a - b;
|
|
};
|
|
|
|
const sum = function(array) {
|
|
const output = array.reduce((total, value) => {
|
|
return total + value;
|
|
}, 0);
|
|
return output;
|
|
};
|
|
|
|
const multiply = function(array) {
|
|
const output = array.reduce((multiplification, value) => {
|
|
return multiplification * value;
|
|
}, 1);
|
|
return output;
|
|
};
|
|
|
|
const power = function() {
|
|
|
|
};
|
|
|
|
const factorial = function() {
|
|
|
|
};
|
|
|
|
// Do not edit below this line
|
|
module.exports = {
|
|
add,
|
|
subtract,
|
|
sum,
|
|
multiply,
|
|
power,
|
|
factorial
|
|
};
|