opendevs
opendevs logo
CoursesInterviewsBlogs

Effective switch

Solidify your knowledge of Conditional Rendering by solving this problem.
Happy sad Tommy

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 content The value of count is zero
  • If count is 1, the component should return a p tag with content The value of count is one
  • and so on...
  • If count is 7, the component should return a p tag with content The value of count is not valid

Solve this easy problem to earn  1  DevCoin image
Output
Coding Area
opendevs logo
CoursesFAQsContact UsPrivacy PolicyTerms Of Service
Copyright © 2023 opendevs
Learn ● Develop ● Ace
All illustrations by Storyset