On this page
Exercise 87: Theme toggle context
Exercise 087: Theme toggle context
Track: react · Difficulty: Hard
Problem
Implement a solution for: Theme toggle context. Your code should be readable, handle edge cases, and include at least one test or demo output.
Requirements
- Use idiomatic JavaScript (or the relevant framework)
- Handle empty, invalid, or boundary inputs
- Add brief comments explaining non-obvious logic
- Avoid unnecessary dependencies
Starter Code
/**
* Exercise 087 — Theme toggle context
* @param { input: unknown } options
* @returns unknown
*/
export function solve(options) {
// TODO: implement
throw new Error("Not implemented");
}
Hints
- Break the problem into smaller functions
- Write examples before generalizing
- Test with at least three input cases
Sample Solution Approach
Parse inputs, validate, transform data, return a structured result. Compare your solution with the official docs for this topic.
Stretch Goals
- Add TypeScript types
- Write unit tests with Vitest or Jest
- Optimize for performance on large inputs