Hi @mariustelcean96 and welcome to the community
You did very well! Congratulations! Some remarks:
- Conditionals 2: The
if...else
structures are correct. The use of alert()
isn’t necessary. For example you could just write response = 'That\'s a great score, you really know your stuff.';
There is already code present, that will display the response on screen. (same for “Conditionals 3”)
- Conditionals 3: The
switch
statement works correctly. Small improvement: When using switch
it is a good thing to make use of the default
option to catch unexpected results. Instead of writingcase (score <= 0 || score >= 100):
response = 'This is not possible, an error has occurred.';
break;
you could put following default
option at the end of the switch
statement:default:
response = 'This is not possible, an error has occurred.';
As you can see, there is no condition on the default
option, because it will automatically be used for everything that you haven’t defined before.
- Conditional 4: Correct! No further comments here
As you wrote there are often multiple solutions for a programming problem (exercises or real-world projects). An important skill in coding is to gain the experience to be able to compare different possibilities and decide which one is the best for your situation. Looking at other people’s code is a great way to broaden one’s mind.
I hope I could give you some helpful feedback and I wish you a great day!
Michael