/*
Practice: Test Your Function and Generate Edge Cases
https://chat.openai.com/
1. Take a minute to read and understand the chunkArray function
2. Ask ChatGPT to generate 3 console.log statements to test the function.
3. Prompt ChatGPt for 5 edge cases
4. Read the edge cases and pick a couple you want your function to
account for (hint: some may involve infinite loops, so don't just run the test cases!)
5. Ask ChatGPT to revise your function based on those edge cases. Be sure
to include instructions (or ask for suggestions) for how you want to deal with them!
*/
/* Prompt: Given an array and a chunk size,
divide the array into many subarrays where each subarray has the specified size. */
function chunkArray(array, size) {
let chunks = [];
for (let i = 0; i < array.length; i += size) {
chunks.push(array.slice(i, i + size));
}
return chunks;
}
console.log(chunkArray([1,2,3,4], 2)); // [[1,2], [3,4]]