scrimba
Note at 0:48
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Note at 0:48
AboutCommentsNotes
Note at 0:48
Expand for more info
main.js
run
preview
console
const alternatingSums = array => [
array.reduce((acc, cur, ind) => !(ind % 2) ? acc + cur : acc, 0),
array.reduce((acc, cur, ind) => ind % 2 ? acc + cur : acc, 0)
];

/**
* Test Suite
*/
describe('alternatingSums()', () => {
it('returns alternating sums of even and odd', () => {
// arrange
const nums = [50, 60, 60, 45, 70];

// act
const result = alternatingSums(nums);

// log
console.log("result: ", result);

// assert
expect(result).toEqual([180, 105]);
});
});
Console
"result: "
,
[
180
,
105
]
,
/index.html
LIVE