in javascript create a function that does the following and named as such, please dont copy the already answered question of this in the incorrect manner thank you!! grouper( xs, n ) This function...


in javascript create a function that does the following and named as such, please dont copy the already answered question of this in the incorrect manner


thank you!!


grouper( xs, n )

This function takes a list of elements xs and an integer n. The function groups every n elements in xs as a list and returns a list of those groups. Each group in the resulting list will therefore be of length n, with the possible exception of the final group. The final group must be non-empty.


Examples




  • grouper( [1,2,3,4,5], 2 ) => [[1,2], [3,4], [5]]

  • grouper( ['a','b','c','d','e'], 4 ) => [['a','b','c','d'],['e']]

  • grouper( [], 3 ) => []




Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here