Skip to content

Commit a1297c8

Browse files
Update chunk-array.md
1 parent a8e4919 commit a1297c8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

snippets/javascript/array-manipulation/chunk-array.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function chunkArray(array, chunkSize) {
1010
if (!Array.isArray(array)) {
1111
throw new TypeError('Expected an array as the first argument.');
1212
}
13-
if (typeof chunkSize !== 'number' || chunkSize <= 0) {
13+
if (typeof chunkSize !== 'number' || Number.isNaN(chunkSize) || chunkSize <= 0) {
1414
throw new RangeError('Chunk size must be a positive number.');
1515
}
1616

@@ -30,4 +30,4 @@ function chunkArray(array, chunkSize) {
3030
// Usage:
3131
const data = [1, 2, 3, 4, 5, 6, 7, 8];
3232
const chunked = chunkArray(data, 3); // Returns: [[1, 2, 3], [4, 5, 6], [7, 8]]
33-
```
33+
```

0 commit comments

Comments
 (0)