Why a and temp is not an array? Please explain it to me!
Thanks!
Your code so far
function chunkArrayInGroups(arr, size) {
// Break it up.
let temp = [];
let num = arr.length / size;
for(let i = 0; i < num; i++){
let a = [];
a.push(arr.slice(0, size));
console.log("a: " + a);
temp.push(a);
console.log("temp: " + temp);
arr.splice(0, size);
}
return temp;
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Safari/605.1.15.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/chunky-monkey