{"ScriptPreparationCode":null,"TestCases":[{"Name":"1","Code":" function chunkArraySlice(array, size) {\r\n let result = []\r\n \r\n for (i = 0; i \u003C array.length; i \u002B= size) {\r\n let chunk = array.slice(i, i \u002B size)\r\n result.push(chunk)\r\n }\r\n \r\n return result\r\n }\r\n\r\nconsole.log(chunkArraySlice([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 5));\r\n","IsDeferred":false},{"Name":"2","Code":"function chunkArray(myArray, chunk_size){\r\n var results = [];\r\n \r\n while (myArray.length) {\r\n results.push(myArray.splice(0, chunk_size));\r\n }\r\n \r\n return results;\r\n}\r\n\r\nconsole.log(chunkArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 5)); \r\n","IsDeferred":false},{"Name":"3","Code":"const chunkIt = (arr, size) =\u003E {\r\n let buckets = []\r\n\r\n // Just create the buckets/chunks storage\r\n for (let i = 1; i \u003C= Math.ceil(arr.length / size); i\u002B\u002B) {\r\n buckets.push([])\r\n }\r\n\r\n // Put in the buckets/storage by index access only\r\n for (let i = 0; i \u003C arr.length; i\u002B\u002B) {\r\n var arrIndex = Math.ceil((i \u002B 1) / size) - 1\r\n buckets[arrIndex].push(arr[i])\r\n }\r\n\r\n return buckets;\r\n}\r\n\r\nconsole.log(chunkIt([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 5));\r\n","IsDeferred":false}]}