What did i do wrong | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What did i do wrong

The conditions keep outputting the default expression https://code.sololearn.com/Wo3itmhcEDVz/?ref=app

16th Jan 2021, 10:29 AM
owadokun Tosin Tobi
owadokun Tosin Tobi - avatar
2 Answers
+ 2
I don't think it's possible to use such conditions in switch. You can write "case 12:", but not "case age <= 12". If you want to do that, use if - else conditions instead.
16th Jan 2021, 11:00 AM
Lukáš Vladař
+ 1
Yes owadokun Tosin Tobi Case statements can never have expression or conditions. case inside switch can have only fixed values.
16th Jan 2021, 1:09 PM
Mohd Aadil
Mohd Aadil - avatar