I have an array and i have to split it into given number and last splited array should accommodate remaining elements if (remaining array size < given_no/2)
for example
var arr = [1,2,3,4,5,6,7,8,9,10,11]
if given_no 2 = Math.round(arr.length/2)= chunk_size 6 = [[1,2,3,4,5,6],[6,7,8,9,10]]
if given_no 3 = Math.round(arr.length/3)= chunk_size 4 = [[1,2,3,4],[5,6,7,8],[9,10,11]]
if given_no 4 = Math.round(arr.length/4)= chunk_size 3 = [[1,2,3],[4,5,6],[7,8,9],[10,11]]
Math.round(11/2) == 6, not5. Did you meanMath.floor(11/2)? - If so,Math.floor(11/3) == 3andMath.floor(11/4) == 2... Also, I'm unclear about "if (remaining array size < given_no/2)".