yourCode = ourCode else { return "fail" };

Tell us what’s happening:

Shouldn’t this technically work? I mean, I understand that the solution removes some extra code taking the line “else if (val >= 5 && val <=10 )” out and replacing it with “else { return “Between 5 and 10” }”

I just want to make sure I totally understand the & operator.

  **Your code so far**

function testElseIf(val) {
if (val > 10) {
  return "Greater than 10";
}

else if (val < 5) {
  return "Smaller than 5";
}
else if (val >= 5 && <= 10) {
  return "Between 5 and 10";
}

}

testElseIf(7);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.47

Challenge: Introducing Else If Statements

Link to the challenge:

For the last condition, remove the else if (val >= 5 && <= 10) and replace it with just else. This is because it’s the last condition and it will always be true if the previous ones are false (assuming that val is always a number)

This isn’t valid. Each side of the && needs to be an independent condition

I wrote it wrong when i was typing my tiny rant

(val >= 5 && val <=10) is the correct way, right?

Thank you - it’s nice to understand WHY they wanted me to do it that certain way. It didn’t explain in the challenge, and technically my way would have worked (val >= 5 && val <=10) is “between 5 and 10” right?

Yes, that’s logically correct, but the challenge requires you to use the else statement.

You’re welcome, I’m glad I could help you. Would you mind marking my post as a solution if I helped you? Thanks.

What error message does the corrected code give?