rendezvous-with-cassidoo-solutions
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v309View latest version
| url: | https://buttondown.com/cassidoo/archive/its-important-to-have-something-to-walk-towards/ |
|---|---|
| date: | 2025-08-18T00:00:00.000Z |
| number: | 418 |
Last week, I had you make playlists with a certain duration! La la la good job Christian, Victor, Laasya, Paul, Elke, Ten, and David!
This week's question:
Write a generator function createLaundryItem() that returns an object
representing a laundry item. This object should have a method nextCycle()
which, when called, advances the item through a series of laundry cycles in
order: "soak", "wash", "rinse", "spin", and "dry". After the final cycle,
subsequent calls to nextCycle() should return "done".
Example:
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"
(you can submit your answers by replying to this email with a link to your solution, or share on Bluesky, Twitter, LinkedIn, or Mastodon)