Convert array to matrix

Take arr and return new array of arrays. Each nested array must contain rowSize items from arr. Examples of behaviour in different cases are below:

toMatrix([1,2,3,4,5,6,7,8,9], 3)
toMatrix([1,2,3,4,5,6,7], 3)
toMatrix([1,2,3], 5)
toMatrix([], 3)