Passed "multiply" using reduce() array method in exercise 08
This commit is contained in:
parent
bcd6da249a
commit
e62fd9013c
|
@ -13,8 +13,11 @@ const sum = function(array) {
|
||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
const multiply = function() {
|
const multiply = function(array) {
|
||||||
|
const output = array.reduce((multiplification, value) => {
|
||||||
|
return multiplification * value;
|
||||||
|
}, 1);
|
||||||
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
const power = function() {
|
const power = function() {
|
||||||
|
|
|
@ -39,11 +39,11 @@ describe('sum', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('multiply', () => {
|
describe('multiply', () => {
|
||||||
test.skip('multiplies two numbers', () => {
|
test('multiplies two numbers', () => {
|
||||||
expect(calculator.multiply([2, 4])).toBe(8);
|
expect(calculator.multiply([2, 4])).toBe(8);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('multiplies several numbers', () => {
|
test('multiplies several numbers', () => {
|
||||||
expect(calculator.multiply([2, 4, 6, 8, 10, 12, 14])).toBe(645120);
|
expect(calculator.multiply([2, 4, 6, 8, 10, 12, 14])).toBe(645120);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue