Created
April 26, 2026 23:19
-
-
Save kauefraga/1ddeb445e42396d7dd63710f1b009949 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const arr = ['A', 'B', 'C', 'D']; | |
| const k = 3; | |
| let current = 2; | |
| console.log(arr[current]); // 'C' | |
| for (let i = 0; i < k; i++) { | |
| current = (current + 1) % arr.length; | |
| } | |
| console.log(arr[current]); // expected: 'B' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment