Chunky Monkey: For loop problem

Tell us what’s happening:
So, in this code i am pushing in sub array’s into my array variable “array” and than filling it with as many elements from the passed in arr argument as size tells me to. Everything is working fine except the first for loop is only running twice instead of running the length of arr. What is the problem here?

Your code so far

 var array = [];
 	for (var i = 0; i < arr.length; i++){
 		array.push([]);
 		//pushes a sub-array into the array
 		for (var j = 0; j < size; j++){
 			array[i][j] = arr.shift();
 			//shifts the first element into the array, this process is repeated based on the 'size' arguement passed in
 		}

 	}
 	return array;
}

chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2);```
**Your browser information:**

Your Browser User Agent is: ```Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36```.

**Link to the challenge:**
https://www.freecodecamp.org/challenges/chunky-monkey

I understand the problem, by the time my first loop runs the second time, the arr.length has already been shrinked due to the .shift() method in my second loop. So, i just put the arr arguement within a variable and set my 1st for loop to less than that

but, as you can see above, even though i used a variable duplicate and set i < duplicate.length, i run into the same problem.