Why does my test pass, even though it doesn’t meet my logic gate?

I’m working on telephone validator on FCC. For some reason this passes 5555555555. Why does my logic gate pass this number? For context, this isn’t my first attempt at this code. I’ve added multiple statements, nested if statements, and it still doesn’t catch it. Why does this evaluate to true? Here’s the code: Answer You need to restate the condition you’re comparing (|| ‘(‘ will always be true): This is due to the fact that && has a greater precedence than the || operator. So without the parenthesis, the ‘(‘ && str.length >= 10 part of the expression is evaluated

Javascript shorthand to call method if object exists

I have a variable and if that variable is a object I would like to call a method on that object, if not I want to do nothing. I’m wondering if there is any reason why I shouldn’t do it like this. …