# Basic Algorithm Scripting: Chunky Monkey HELP

``````function chunkArrayInGroups(arr, size) {
var arr1=arr.slice(0,size);
var arr2=arr.slice(size,);
var temp = [[], []];
temp[0].push(arr1);
temp[1].push(arr2);

console.log(temp);
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3);
``````

Tell me why the program does not make such a decision.

Write a function that splits an array (first argument) into groups the length of `size` (second argument) and returns them as a two-dimensional array.

What do you mean by “make a decision”? It should return a value and the value will be an array. Your function is not returning anything at the moment. You are using `console.log` to display something to the console, but that is not the same as returning a value.

with return() the same does not pass the test. I found the problem, but I don’t understand why this happens.

`return` is not a function. It is a key word in JavaScript. I suggest you review the Basic JavaScript section where the return statement is first introduced.

``````function chunkArrayInGroups(arr, size) {
var arr1=arr.slice(0,size);
var arr2=arr.slice(size,);
var temp = [[], []];
temp[0].push(arr1);
temp[1].push(arr2);

return temp;
}
chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3);
``````

but even so does not work

That is because you are returning:

``````[ [ [ 0, 1, 2 ] ], [ [ 3, 4, 5 ] ] ]
``````

``````[ [ 0, 1, 2 ] , [ 3, 4, 5 ] ]
``````

However, what if size were 2 in instead of 3? You are attempting to hard code temp, when instead you should be “building” it from an empty array `[ ]`.

and there is an option how to make my code work? Without changing the meaning. I can not find on the Internet. How to add two arrays into one, but so that they are two?

You should have already learned about the `slice` method which allows you to return “part” of an existing array. If you could take the “parts” of a a certain size and “push” them into a new array, that is an approach you could take. If you do not remember the slice method, see below for the challenge where it was introduced.

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/copy-array-items-using-slice

Thank you.

I did not understand the condition correctly.
I am Russian, I decide with a translator)))

With splice () it turned out, but only for a special case.