2024-01-11 08:56:09 +00:00
|
|
|
const add = function(a, b) {
|
|
|
|
return a + b;
|
2024-01-11 08:52:05 +00:00
|
|
|
};
|
|
|
|
|
2024-01-11 08:56:59 +00:00
|
|
|
const subtract = function(a, b) {
|
|
|
|
return a - b;
|
2024-01-11 08:52:05 +00:00
|
|
|
};
|
|
|
|
|
2024-01-11 08:59:22 +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
|
|
|
};
|
|
|
|
|
2024-01-11 09:00:30 +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
|
|
|
};
|
|
|
|
|
2024-01-11 09:01:48 +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
|
|
|
|
};
|