Tell us what’s happening:
Hello everyone!
This code is working if I put it into an html and test it in the browser, but it’s showing me “TypeError: cannot set property ‘counter’ of undefined”.
Could anyone tell my why is this?
Thank you in advance
Alex
Your code so far
this.counter = size;
console.log('counter is: ' + size);
// initialize the final 2D arr
var finalArr = [];
//loop through it every 'counter' item
for (var i = 0; i < arr.length; i+=counter) {
console.log('i= ' + i); //just for me to check
var sliceArr = arr.slice(i, size);
finalArr.push(sliceArr);
size *=2;
console.log('sliceArr= ' + sliceArr); //just for me to check
}
console.log(finalArr); //just for me to check
return finalArr;
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4);```
**Your browser information:**
Your Browser User Agent is: ```Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3230.0 Safari/537.36```.
**Link to the challenge:**
https://www.freecodecamp.org/challenges/chunky-monkey