if you want to check if a number is between two other, you should go like this
for (var person = 2; -10 < person && person < 10; person --) {
console.log(person);
}
when you chain -10<person<10
, it gets interpreted as ((-10<person)<10)
, and first one is true till it becomes lesser than -10 or equals to it, so first the first part till it person becomes -10 it is like (true<10)
and true is 1.so it returns true.
for the second part when person becomes lesser or equals to -10 (-10<person)
returns false and false is 0 and it surely is lesser than 10 --> (false<10)
, so it stays true forever and there goes infinite loop.