Chunky Monkey - Two solutions, but I don't understand the difference

Why += is working with one, but not with another?

Spoiler

solution 1

Spoiler

solution 2

second one changes arr.length, and not i, first one changes i and keep arr.length constant

1 Like

Ah! So “i+size” does nothing?

yep, it does nothing

What you mean that ot changes arr.length?

arr = arr.slice(size) changes the array stored in arr, so arr.length is different at each iteration

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.