opendevs
Happy sad Tommy

Effective switch

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

Difficulty

easy

Solve the practice problems to earn    DevCoin image 
Coding Area
Output

Copyright © 2022 opendevs

Learn ● Develop ● Ace
All illustrations by Storyset