linkedin Skip to Main Content
Just announced! We now support spreadsheets
Back to blog

Code Challenge: React Context API Array Toggle

Coding Challenges

React context API allows developers to pass data through a component tree without having to pass props manually at every level. React’s context API finds its usage in large application components required to share data at different nesting levels.

For this tiny interview, a JavaScript array containing foods have been provided, use this array to implement a feature that enables the content of the array to be toggled using the React Context API.

Implement your solution in the sandbox below:

Want some more challenge?

If you completed the original goal, why not try the following bonus exercise?

  • Allow more foods to be added to be added to the foods array by providing a custom controlled input component.

Code challenge solution

Verify your solution with the official solution in this sandbox.

More resources

We have made available these extra resources to improve your React coding skills:

Want to conduct interviews on this platform?

Check out CoderPad : pick any interview question or create your own, then invite your candidate to a shared live-coding session on an IDE like this one. You even get 2 free interviews per month forever using this registration link!