Chunking for RAG
Retrieval-Augmented Generation (RAG) splits long documents into chunks small enough to embed and retrieve. A simple strategy: group every N words together.
Your task
Write chunkWords(text, size) that splits text (space-separated words) into
chunks of at most size words, returning an array of chunk strings.
β‘ 40 XP
solution.jsRuns in your browser
Loading editorβ¦
Tests3 to pass
chunks of 2
fewer than size
chunks of 1
Run your code to check these.