Interview Phone - Frontend Google

What do the following lines output, and why?

console.log(1 < 2 < 3);
console.log(3 > 2 > 1);

The first statement outputs true, as expected.

The second statement outputs false due to how the operator associativity for < and > works in JavaScript. It compares from left to right, so 3 > 2 > 1 translates to true > 1. Since true is equivalent to 1, it then compares 1 > 1, resulting in false.