Tell us what’s happening:
I’m trying to solve this challenge with the code below but it’s not working. No of the tests are passing and when I run it the window hangs. Please have a look and tell me what’s wrong with it?
Your code so far
function chunkArrayInGroups(arr, size) {
// Break it up.
var new_arr = [];
while(arr.length > size) {
var An_array = [];
for(var i = 0; i < size; i++) {
An_array.push(arr[i]);
}
new_arr.push(An_array);
arr.slice(0, size);
}
var arr1 = [];
for(var j = 0; j < arr.length; j++) {
arr1.push(arr[j]);
}
new_arr.push(arr1);
return new_arr;
}
chunkArrayInGroups(["a", "b", "c", "d"], 2);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/chunky-monkey