Last active
August 18, 2025 16:28
-
-
Save kirkegaard/fb4bd56ecaf193fd2ab4b79d7a3a24f6 to your computer and use it in GitHub Desktop.
@cassidoo mailing list question
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
| function createLaundryItem() { | |
| let count = 0; | |
| const tasks = [ | |
| "soak", | |
| "wash", | |
| "rinse", | |
| "spin", | |
| "dry", | |
| ]; | |
| const next = () => { | |
| if (count < tasks.length) { | |
| return tasks[count++]; | |
| } | |
| return "done"; | |
| } | |
| return { | |
| nextCycle: next, | |
| } | |
| }; | |
| let towel = createLaundryItem(); | |
| console.log(towel.nextCycle()); // "soak" | |
| console.log(towel.nextCycle()); // "wash" | |
| console.log(towel.nextCycle()); // "rinse" | |
| console.log(towel.nextCycle()); // "spin" | |
| console.log(towel.nextCycle()); // "dry" | |
| console.log(towel.nextCycle()); // "done" | |
| console.log(towel.nextCycle()); // "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment