Open xasterKies opened 2 years ago
Given an array and chunk size, divide the array into many where the subarray is of length size .Make use of functions and methods where necessory
You can code this with any language of you choice!
chunk([ 1, 2, 3, 4], 2) -----> [ [ 1, 2 ], [ 3, 4 ] ] chunk([ 1, 2, 3, 4, 5 ], 2) -----> [ [ 1, 2 ], [ 3, 4 ], [5] ] chunk([ 1, 2, 3, 4, 5, 6, 7, 8 ], 3) -----> [ [ 1, 2, 3], [ 4, 5, 6 ], [7, 8] ] chunk([ 1, 2, 3, 4, 5 ], 4) -----> [ [ 1, 2 , 3, 4 ], [5] ] chunk([ 1, 2, 3, 4, 5 ], 10) -----> [ 1, 2 , 3, 4, 5 ]
please assign me
Assign me please
Done @Blanco237
Directions
Given an array and chunk size, divide the array into many where the subarray is of length size .Make use of functions and methods where necessory
You can code this with any language of you choice!
Examples
chunk([ 1, 2, 3, 4], 2) -----> [ [ 1, 2 ], [ 3, 4 ] ] chunk([ 1, 2, 3, 4, 5 ], 2) -----> [ [ 1, 2 ], [ 3, 4 ], [5] ] chunk([ 1, 2, 3, 4, 5, 6, 7, 8 ], 3) -----> [ [ 1, 2, 3], [ 4, 5, 6 ], [7, 8] ] chunk([ 1, 2, 3, 4, 5 ], 4) -----> [ [ 1, 2 , 3, 4 ], [5] ] chunk([ 1, 2, 3, 4, 5 ], 10) -----> [ 1, 2 , 3, 4, 5 ]