Controlling Logical Operators with Bigger Expressions

I’m wondering why this doesn’t work:

let num = 2; 
let evenOrOdd = 'even'; 

console.log((num % 2) && (evenOrOdd == 'even')); 
console.log(num % 2 && evenOrOdd == 'even'); 


console.log(!(num % 2) && (evenOrOdd == 'even')); 

I expected true, but I get false. Is there no way to evaluate two expressions surrounding a logical operator without first assigning those two expressions to separate variables? In other words: let condition1 = num % 2 && let condition2 = ‘even’

The condition (num % 2) is falsy when num is even and truthy when num is odd. I suspect this is the opposite of what you want.

I’m gonna cry. Gosh. I think I had the same issue in another problem I was working on this week. JeremyLT is bossy.

I’m glad I can come here to ask questions without judgment : )


It’s the little things that send us in debugging circles. That’s what fresh eyes help with : )