BeginnerCoder

Lesson 7 — Array chunking

Work in batches

Sending 10,000 emails at once can overload a server, so you split the list into chunks (batches) of a fixed size. slice(start, end) copies part of an array — the end index is not included.

[1, 2, 3, 4, 5].slice(2, 4);   // [3, 4]

A loop that jumps by n each time and slices n items builds the chunks.

Why it matters: batching keeps memory and network use under control in real backends.

Want it another way?
Task

Finish chunk(): push a slice of n items on each step, so 5 numbers in groups of 2 make 3 batches.

Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.

← Back
Next →
Test your knowledge

A quick 3-question quiz on this lesson — instant feedback.

Enjoying this lesson? Share it.