How is this illustrate?

Tell us what’s happening:
Describe your issue in detail here.

i do confused how does this explain in plain steps.

the loop starts with 0 , and when (i + = size) every time… to me it look like this (0, 2, 4,…). so the loop stop at 4 cause 4 is the length of arr

 for(let i = 0; i < arr.length; i += size){
    newArr.push(arr.slice(i, i + size))
  }

but i don;t get it for the push, too me it look like the push look like this push(arr.slice(0, 0))…push(arr.slice(2, 4))…push(arr.slice(4, 6))- which i see how the i are iterate.

hence that. though the result would be
newArr = [[a], [c, d], ]

i know i’m wrong, but i’m still cant find my self to explain it.

  **Your code so far**

function chunkArrayInGroups(arr, size) {
let newArr = [];
  for(let i = 0; i < arr.length; i += size){
    newArr.push(arr.slice(i, i + size))
  }

return newArr;
}

console.log(
chunkArrayInGroups(["a", "b", "c", "d"], 2));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36

Challenge: Chunky Monkey

Link to the challenge:

Hello, I put spoiler tags around your code - we should always do that with working solutions.

the loop starts with 0 , and when (i + = size) every time… to me it look like this (0, 2, 4,…)

Yes.

so the loop stop at 4 cause 4 is the length of arr

Yes, it does 0, then 2, then when it sees 4, it stops immediately.

but i don;t get it for the push, too me it look like the push look like this push(arr.slice(0, 0))…push(arr.slice(2, 4))…push(arr.slice(4, 6))

No, that last one doesn’t get run. Remember that the condition was i < arr.length. The for loop will only run if that is true. When i is 4, that is false so the loop will stop. If we had used <= instead of <, then it would still run that last time. But since 4 < 4 is false, the for loop will stop before that iteration.

I like to use log statements when I am confused by something. Add this:

console.log('i =', i, '    pushing ', arr.slice(i, i + size).toString())

as the first line in your for loop and see if that helps clear things up.

oh yea, i see. that’s make sense. arr.slice(0-2) & arr.slice(2,4)

thanks.