Creating subarrays
The function will divide the original array into a number of sub-arrays according to the provided number N, each sub-array should have N elements.
Sample Code:
function arrNested(arr,n) {
// Enter your logic here...
}
Examples:
Input: [1,2,3,4,5,6],2
Output: [[1,2],[3,4],[5,6]]
Explanation: Each sub-arrays have 2 elements.
Input: [1,2,3,4,5,6],3
Output: [[1,2,3],[4,5,6]]
Explanation: Each sub-arrays have 3 elements.