Skip to content

Commit

Permalink
more README updates to align the demo code
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed Sep 18, 2024
1 parent 7a54312 commit a396b73
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ let chunksOf4 = Array.from(digits.values().chunks(4));
A more flexible solution is a sliding window method, usually named `windows`:

```js
let windowsOf3 = Array.from(digits.windows(3));
let windowsOf3 = Array.from(digits.values().windows(3));
// [ [0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9] ]

let windowsOf2AdvancingBy3 = Array.from(digits.windows(2, 3));
let windowsOf2AdvancingBy3 = Array.from(digits.values().windows(2, 3));
// [ [0, 1], [3, 4], [6, 7], [9] ]
```

`chunks` is just a specialisation of `windows` where `chunks(n)` is equivalent to `windows(n, n)`.

```js
let chunksOf4 = Array.from(digits.windows(4, 4));
let chunksOf4 = Array.from(digits.values().windows(4, 4));
// [ [0, 1, 2, 3], [4, 5, 6, 7], [8, 9] ]
```

Expand Down

0 comments on commit a396b73

Please sign in to comment.