I am trying to solve it recursively and wanna set proper base cases.
There are no test cases for size ===0.
But i guess chunkArrayInGroups(arr, size) should return empty array for the case above? Is that correct?
Edit. For moderators.
I accidentally posted it in General subforum. Is there an opportunity to move thread in JS subforum?
I didn’t write recursive step yet.
But I think I will use base case for size===1:
function chunkArrayInGroups(arr, size) {
//base case
if (size===1) {
return [arr]
}
//to do: figure out recursive step
//try to grasp difference between cases size=== 3 and size===4
//for some testArray
}
basecasecheck = chunkArrayInGroups(["a", "b", "c", "d"], 1);
console.log(basecasecheck);//[ [ 'a', 'b', 'c', 'd' ] ]
I think in recursive step will be some kind of call like below:
chunkArrayInGroups(arr, size + 1)
For now I didn’t figured out what methods I wanna use, but I have a general idea
So I need to know how function should behave when size < 1 to add some more base cases
Your size
should not change at all during this process…
Makes sense, I’ll work on recursive step and will provide more info after that
I guess I gave little more info than needed in the original post.
My question:
What is expected behaviour for chunkArrayInGroups(arr, size) when size < 1?
There are no such tests in the challenge step. Should I be bothered with this at all?
The challenge does not specify but I would probably expect an empty array since an array of size zero has to be empty.
That is up to you.
1 Like
system
Closed
9
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.