scrimba
Solution for day 3 of #javascriptmas
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

Solution for day 3 of #javascriptmas
AboutCommentsNotes
Solution for day 3 of #javascriptmas
Expand for more info
main.js
run
preview
console
function chunkyMonkey(values, size) {
var chunkyArray = [];
for (let i = 0; i < values.length; i += size) {
// Make slice & add slice to array
chunkyArray.push(values.slice(0 + i, size + i));
}
return chunkyArray;
}




/**
* 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