# Basic Algorithm Scripting - Chunky Monkey

Tell us what’s happening:
Can somebody please explain to me my confusion in this problem, though i already solved the problem but i was bewildered when line number 9 does not exist, it return undefined? As a challenge to myself i turn this into recursive function but when i only use the return in line number 3 it does not return the actual result though res = the desired result;

``````  **Your code so far**
``````
``````function chunkArrayInGroups(arr, size, res = []) {
// return when arr argument is empty
if(arr.length < 1) return res;
// slice through array
res.push(arr.slice(0, size));
// do a recursive
chunkArrayInGroups(arr.slice(size),size,res);
// if not present return undefined
return res;
}

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

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

Challenge: Basic Algorithm Scripting - Chunky Monkey