Effective switch
Solidify your knowledge of Conditional Rendering by solving this problem.
Savitri is tired of writing multiple if/else block. Please help her by writing a effective switch case which should fulfill the below requirements.
The component will accept a prop called count
which will be of type number and depending upon the value of prop, the component should return a p
tag with content in the format: The value of count is ${count}
.
The minimum & maximum value of prop count
could be 0 & 5 respectively. For any other value of prop count
, the component should return a p
tag with content in the format: The value of count is not valid
.
Ex:
- If count is 0, the component should return a
p
tag with contentThe value of count is zero
- If count is 1, the component should return a
p
tag with contentThe value of count is one
- and so on...
- If count is 7, the component should return a
p
tag with contentThe value of count is not valid
Solve this easy problem to earn 1