CodStak Weekly Challenge #3: Nested Checkboxes and Launch of Podcast
New Challenge and Podcast announcement
Hey coders👨🏽💻👩🏽💻,
Today’s challenge is about nested checkboxes. You can access the challenge here:
This is one of the most commonly asked frontend interview questions and I want you to take this challenge before anyone asks you. It is crucial to understand the requirements of the challenge, which is as follows:
Description:
Create a React component that implements a nested checkbox structure. When the user selects a parent checkbox, all its child checkboxes should also be selected. If the parent is deselected, the child checkboxes should also be deselected. Additionally, if all the child checkboxes of a parent are individually selected, the parent checkbox should automatically toggle to a selected state.
Requirements:
Display a nested structure of checkboxes:
Parent Checkbox 1
Child Checkbox 1.1
Child Checkbox 1.2
Functionality:
Clicking a parent checkbox should toggle the state of all its child checkboxes. Clicking on individual child checkboxes should not affect other checkboxes directly. If all children of a parent checkbox are selected individually, the parent checkbox should automatically get selected. If at least one child checkbox is unselected, the parent checkbox should become unselected. The initial state of all checkboxes should be unchecked.
The challenge seems easy but you will be surprised how many can’t solve it in one go, can you solve it?
As you can see, if one child is unselected, it should unselect the Parent, and if the Parent is selected, it should select all children.
Good luck with this question!
The second big news is that I started a podcast where we will talk about everything related to web development. Here is the link to the first episode about “Mastering the useEffect hook”.
The podcast's goal is to talk deeply and freely about important stuff in the world of web dev. Instead of videos, I found this way I don’t have to spend too much time editing and planning the video. With just audio, I can read through my notes and share my personal experiences. And yeah, in the future, we will bring guests from time to time to gain their experience as well.
Well, that’s all folks from this week. Will see you next week with a new challenge and a new podcast video.
A lot of stuff is happening and in the coming days, I will share it with you. Till then, take care and enjoy the last few days of December 2024.