function chunkyMonkey(values, size) {
// write code here
// set empty array to hold split values
const tempArray = [];
let index = 0;
for(let i = 0; i < values.length - 1; i += size) {
tempArray.push(values.slice(i , size + i));
console.log(i);
index += size;
}
// there is only the remaining values that needs to be push to the array
if(index < values.length ){
tempArray.push(values.splice(index));
}
//return the nested array
return tempArray;
}
/**
* 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"]]);
});
});