Don' t get the question

I’m stuck and honestly, I don’t get the question.
Describe your issue in detail here.

  **Your code so far**
function testLogicalOr(val) {
// Only change code below this line

if (val < 10 || > 20) {
  return "Outside";
}

if (val) {
  return "Outside";
}

// Only change code above this line
return "Inside";
}

testLogicalOr(15);
  **Your browser information:**

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

Challenge: Comparisons with the Logical Or Operator

Link to the challenge:

You are on the right track, you are just missing something. Notice the first comparison you use val:

val < 10

But in the second comparison you don’t:

> 20

So there is nothing on the left side of the > to compare to. This is actually a syntax error and thus your code won’t run. What do you think you need to do to fix this?

Also, you want to get rid of the second if statement completely, don’t you?

1 Like

I forgot to use the Val in the second comparison. Also didn’t get rid of the second if. All I can think of that could also be wrong is the spacing. I made the changes you suggested I’ll continue trying.

Thank you for your feedback.

Those were the only two changes I had to make to your code. There were no spacing issues for me. If you get stuck then please paste your updated code in here and we’ll be happy to help you out.

1 Like

Hello. I made the changes but can’t pass. This is what I have. Thank you in advance.

gg

  if  (val  <  10  ||  val   >  20  ) {
    return "Outside";
  }

  if (val) {
    return "Outside";
  }

  // Only change code above this line
  return "Inside";
}

testLogicalOr(15);

I thought you were going to get rid of the second if statement? Do you know why that needs to be removed?

Yes, the challenge is to use only one val and use || . I made the change. Thank you again.

gg

if ( val < 10 || val > 20 ) {
return “Outside”;

question: does it matter if my computer doesn’t have a || only button? The one I’m using is a ||\ combined .

I’m not sure I understand your question. You create a logical OR by typing the | (i.e “pipe”) button twice. Is this what you are doing?

Correct. That’s what I am doing.

HI @gily34 !

Were you able to figure it out?

Not yet. The feed back has been awesome. Please share any insight you may have.

What happened when you did this part?

Your answer should only be one if statement.
Not two

Hope that helps!

I got rid of it. Not sure why it’s showing up on your end

What do mean it is showing up on my end?

Can you explain what you mean here?

I thought you had asked why I didn’t delete one of the if’s. I said I had. Lol. I still can’t pass.

What I have.

if ( val  <  10  ||  >  20  ) {

This code has errors in it

You are missing a }
and you are missing the code inside the if statement.

Let’s go back to your earlier code here

We only wanted you to delete the second if statement here

Once you do that the test should pass.

Make sure not to touch the first if statement because that was correct.

Hope that helps!

Good morning. Thank you so much. I was able to pass the challenge. Problem : I wasn’t deleting the “outside “part of the second if statement.

Thanks for you feedback. I was finally able to pass the challenge. Problem: I was not deleting the entire second if statement.

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