Interview Question: Group Array Elements

Problem

Given an array of length >=0, and a positive integer N, return the contents of the array divided into N equally sized arrays.

Where the size of the original array cannot be divided equally by N, the final part should have a length equal to the remainder.

Solution

The method groupArrayElements(array, n) is available on window and can be called in the browser console.