Why on this and Why on that?

Why on this and Why on that?
0

#1

I think freeCodeCamp can do a better job at letting us know why on certain problem’s ! Why you would put this here or why you would use this ! Instead of them expecting us to know certain thing when we are learning how to do the programming language it doesn’t make sense ? If I had to grade them On that I would give them an F on it …


#2

Since you have given no specifics or examples, I am not sure what use this post is going to serve.


#3

Comparisons with the Logical Or Operator

Combine the two if statements into one statement which returns “Outside” if val is not between 10 and 20, inclusive. Otherwise, return “Inside”.

changing: if (num > 10) {
return “No”;
}
if (num < 5) {
return “No”;
}
return “Yes”;

example: if (num > 10 || num < 5) {
return “No”;
}
return “Yes”;

answer: if ((val >= 10 || val == 10) && val <= 20) {
return “Inside”;
}
return “Outside”;
}

Nothing in the wording said to use both logical || and && it took hour’s to figure out …


#4

Nothing in the instructions or examples show using the && operator, because the challenge is meant to be be solved with only one || operator. The example shows you exactly how to do it (using different numbers of course). You will also notice the code section has comments like:

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

The above means, you should not change the return “Inside”; line.

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

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

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

#5

I Did that and 0 and 9 would not take for some reason ?


#7

When I run the solution I posted above, it works fine for 0 and 9. You might need to double check your code for a typo. If you copy/paste the solution I provided above, it should work. If not, you may need to refresh your page and try to the run the tests again.