Tell us what’s happening:
Just to be clear, I have modified the return line to return tdArray;
and it works fine, returning the two dimensional array. My question is : how come return "Resulting Array" + tdArray;
returns the values in a one dimensional array? What is the mechanism and what changed there? Thank you in advance.
Your code so far
function chunkArrayInGroups(arr, size) {
let tdArray = [];
let indexEnd = size;
console.log("Initial Array and size: ",arr,size);
for (let i = 0;i < arr.length;i += size) {
tdArray.push(arr.slice(i,indexEnd));
indexEnd+=size;
console.log("Array in loop: ",tdArray);
}
return "Resulting Array: " + tdArray;
}
console.log(chunkArrayInGroups(["a", "b", "c", "d"], 2),"\n -----------------------------");
**Your browser information:**
User Agent is: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0
.
Challenge: Chunky Monkey
Link to the challenge: