Tell us what’s happening:
I just want this line of code explained more, I can’t get why it’s working. Hint #3 doesnt explain whats happening at all with this small piece of the code and I really think it should be, I have looked around to see why it produces the results it does, but I just can’t understand. Can someone please help me understand what I assume is a super basic concept that I am way over thinking?
This is the line I’d like explained, what im not getting is the first param being i, if i is 2, then nothing should work, so i isnt 2? is it 0, and the next i is 2? :
arr.slice(i,i + size)
function chunkArrayInGroups(arr, size) {
let newArr = [];
for(let i = 0;i < arr.length;i += size){
let sliced = arr.slice(i,i + size);
newArr.push(sliced);
} console.log(newArr)
return newArr
}
chunkArrayInGroups(["a", "b", "c", "d"], 2);
Please someone free me from my monkey brain.
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0
Challenge: Chunky Monkey
Link to the challenge: