mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-06-05 15:09:09 +09:00
New solution to match updated test syntax
See separate PR "Removed array syntax in multiply test #359" https://github.com/TheOdinProject/javascript-exercises/pull/359
This commit is contained in:
@@ -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 sum = 1
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
sum *= args[i]
|
||||
}
|
||||
return sum
|
||||
}
|
||||
|
||||
const power = function (a, b) {
|
||||
return Math.pow(a, b);
|
||||
|
||||
Reference in New Issue
Block a user