[Assessment] Conditionals 2–4 skill test

Hi! :smile:

Can someone please verify those exercises?

Conditionals 2

Conditionals 3

Conditionals 4

It’s about the exercises written here.

After finishing the exercises I searched through a few similar threads to find out how other people solved them. There seem to be many ways of solving a programming problem. :crazy_face:

Hi @mariustelcean96 and welcome to the community :wave:

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 writing
    case (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 :wink:

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

1 Like

Hi Michael!

Thank you for you comments. I did the mentioned modifications.

All the best,
Marius