Assessment wanted for JS test - Conditionals 2, 3, 4

Hi! Could someone kindly check my work on Test Your Skills - Conditionals 2, 3, & 4?

Conditionals 3 was especially tricky to me, but I thought using switch (true) might be a good idea. I found it on this MDN page.

Thank you in advance! :slight_smile:

My Work
Conditionals 2

Conditionals 3

Conditionals 4

Test page

Nice work, @Risa!

All three tasks are well solved. Congrats! :clap:

You used (machineActive === false) (task 2) and (machineActive === true) (task 4). These can be shortened to (!machineActive) and (machineActive). You already did it in task 3.

Most learner struggle with finding this unusual way of using switch, but your decision was correct. When you think about what switch essentially does: It compares the value after switch with the values after case and executes the code if they match. So the behavior makes total sense (although it isnโ€™t the โ€œclassicโ€ example of using the switch statement).

See you,
Michael

1 Like

Hi @mikoMK,

Thank you so much!

Oh yeah I must have read that I could shorten the conditionals to test whether it is true or not, but somehow I forgot to do that! :scream:

Thank you for reminding me! :blush:

1 Like