Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAditya Gawade
1,182 Pointsneed help. is the problem so that constant has month but switch statement has monthS?
Next Question A The above code will not compile because switch statements need to be exhaustive with case statements for all expected values or a default statement. B The code is valid and isn't missing anything. C It's missing case statements for the rest of the months.
1 Answer
Fernando Boza
25,384 PointsHi Aditya the issue in the statement, all values, in this case months 1 - 12 must have a case OR a default statement. Either all have a case or at least add a default. Thought if you do decided to add a case to all values, then there would be no need to add a default value.
The above code will not compile because switch statements need to be exhaustive with case statements for all expected values or a default statement.