Need to Help , Javascript Building blocks : consitionals assessment 3

Getting stuck in this assessment (conditinals 3) , , can you help me ? that’s my approach :
let response;
let score = 75;
let machineActive = true;

if(machineActive) {
// Add your code here
switch (score) {
case score < 0 || score > 100 :
response = ‘This is not possible, an error has occurred.’;
case score >= 0 && score <= 19 :
response = ‘That was a terrible score — total fail!’;
case score >= 20 && score <= 39 :
response = ‘You know some things, but it’s a pretty bad score. Needs
case score >= 40 && score <= 69 :
response = ‘You did a passable job, not bad!’;
case score >= 70 && score <= 89 :
response = ‘That’s a great score, you really know your stuff.’;
case score >= 90 && score <= 100 :
response = ‘What an amazing score! Did you cheat? Are you for real?’;
} else {
response = ‘The machine is turned off. Turn it on to process your score.’;

// Don’t edit the code below here!

section.innerHTML = ’ ';
let para1 = document.createElement(‘p’);
let para2 = document.createElement(‘p’);

para1.textContent = Your score is ${ score }.;
para2.textContent = response;


Hi @hechaichiraoof and welcome to the community :wave:

Your case expressions are correct, but here is something wrong with switch (score). For a case clause to be selected the expression has to have the same value as the switch expression (with a strict comparison ===).

The case expressions are either true (if the score matches) or false (if the score doesn’t match), but the switch expression is a number.

How could you change switch (score) to make it work?

Solution Change "switch (score)" to "switch (true)"

I hope that helps! Tell me if something isn’t clear :slightly_smiling_face:.
If you plan to post another task it would be easier for us, if you could put it in an online editor like (or similar) and share a link here.

Have a nice day,

PS: Your email address is visible in your post. I think it somehow ended up in the optional “name” field of your profile. I recommend removing it.

1 Like

Thanks a lot @mikoMK for your help. :innocent: :innocent:
Your explication was brief and very helpful at same time:green_heart: :green_heart:
I wish you all the best .
Thank again!!

1 Like