Need some clarification here plz!

Tell us what’s happening:
Describe your issue in detail here.
So I did this exercise after watching a video explaining it and while I understood the idea of the exercise I read on the hint section that people have been saying that the instructions are unclear as to how to do this exercise. I am wondering where in the practice I need to apply the === property since that is part of the exercise.

Thank you guys for the help! I really appreciate it :slight_smile: you are all awesome! <3

  **Your code so far**

function caseInSwitch(val) {
var answer = "";
// Only change code below this line
switch (val) {
case 1:
answer = "alpha";
break;
case 2:
answer = "beta";
break;
case 3:
answer = "gamma";
break;
case 4:
answer = "delta";
break;
}


// Only change code above this line
return answer;
}

caseInSwitch(1);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15

Challenge: Selecting from Many Options with Switch Statements

Link to the challenge:

Hi @Sherif123 !

You don’t need to use the === operator.
The way switch statements work is that it will use strict comparision (===) for the cases and the expression here

For example, when I call the function here, the number 1 matches case 1.

But if I changed the function call to this,

caseInSwitch('1');

then none of the cases would match because ‘1’ is not the same as 1.
One is a string while the other is a number.

Here are the docs going into the definition of switch statements

Hope that is clear!

1 Like

Thank you so much for your help!! that clarifies it for me :slight_smile: thank youuuuu.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.