scrimba
Note at 0:51
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:51
AboutCommentsNotes
Note at 0:51
Expand for more info
main.js
run
preview
console
function chunkyMonkey(values, size) {
const ret = [];

let n = Math.floor(values.length / size);
if (values.length % size > 0) n++;

for (let i = 0; i < n; i++) {
ret.push(values.slice(i * size, (i + 1) * size));
}

return ret;
}

/**
* Test Suite
*/
describe('chunkyMonkey()', () => {
it('returns largest positive integer possible for digit count', () => {
// arrange
const values = ["a", "b", "c", "d"];
const size = 2;

// act
const result = chunkyMonkey(values, size);

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

// assert
expect(result).toEqual([["a", "b"], ["c", "d"]]);
});
});
Console
"result: "
,
[
[
"a"
,
"b"
]
,
[
"c"
,
"d"
]
]
,
/index.html
LIVE