Merge pull request #364 from fruddenfeldt/dev
New solution to match updated test syntax
This commit is contained in:
commit
8692f0ea18
1 changed files with 7 additions and 5 deletions
|
@ -10,11 +10,13 @@ const sum = function (array) {
|
|||
return array.reduce((total, current) => total + current, 0);
|
||||
};
|
||||
|
||||
const multiply = function (array) {
|
||||
return array.length
|
||||
? array.reduce((accumulator, nextItem) => accumulator * nextItem)
|
||||
: 0;
|
||||
};
|
||||
const multiply = function(...args){
|
||||
let product = 1;
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
product *= args[i];
|
||||
}
|
||||
return product;
|
||||
};
|
||||
|
||||
const power = function (a, b) {
|
||||
return Math.pow(a, b);
|
||||
|
|
Loading…
Reference in a new issue