Test not running - Comparisons with the Logical And Operator

Test not running - Comparisons with the Logical And Operator
0

#1

This tutorial’s page is not running the test. Tried resetting the code several times. Also tried with my phone and still won’t run the test. Was having some similar issues in the lessons before this one. But managed to run the test on those. Not this one. (Won’t be able to advance until it’s figured out)

Your code so far


function testLogicalAnd(val) {
  // Only change code below this line

  if (val <= 50 && val >= 25) {
      return "Yes";
    }
  }

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

// Change this value to test
testLogicalAnd(10);

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 10575.58.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/comparisons-with-the-logical-and-operator/


#2

Can you try on a desktop or laptop? I find the tests more predictable there.


#3

It will not run, because you have a syntax error. The error is caused by you having an extra } after the if statement. Delete the extra } and the tests should run.


#4

Got it, thanks. So used (or spoiled) to have a response when something is wrong (even syntax), that the lack of any response misled me. Thanks again…


#5

If you would have looked at the browser’s console (Ctrl+Shft+J in Chrome) you would have seen the error.


#6

Was -looking at the console- ever mentioned anywhere in the tutorial?


#7

Yeah it is only mentioned in the debugging section which unfortunately comes later. go figure.


#8

Not sure about debugging in the earlier sections of the new curriculum, but I believe they have added one later in the curriculum. Also, I believe they are working to add the console output back to the new site. Until then, you did the right thing and asked the forum about how to view possible errors without the old console feature.


#9

You can also do right click --> inspect --> console (at the top).


#10

Here’s my code. The syntax is fine, but the test button isn’t working, again.

function testLogicalAnd(val) {
  // Only change code below this line

  if (val <= 50 && >= 25) {
      return "Yes";
  }

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

// Change this value to test
testLogicalAnd(10);

#11

I do not see a function declaration in the code you just posted.


#12

That’s because I’m still figuring out how to past code in comments. It’s all here now.


#13

Your if statement condition is the problem. When you make any comparison with a comparison operator such as >= to another value, you must always proceed it with another value (or variable in this case).

For example, if I want to check if val is greater than 3 and less than 10, I would write:

if (val > 3 && val < 10) {

#14

Needed an extra val, got it. And it worked, thanks!

Now if only the test button actually ran whenever I made a syntax error so I’d know I was making a mistake so I could fix it myself.