Okay, so here is what I typed out.
if (collisionDetectionRules.every(el => el === true)){
player.velocity.y = 0;
return;
}
It looks okay, but I’m not entirely sure why it’s not accepting this.
It might be a subtle mistake I’m missing.
Okay, so here is what I typed out.
if (collisionDetectionRules.every(el => el === true)){
player.velocity.y = 0;
return;
}
It looks okay, but I’m not entirely sure why it’s not accepting this.
It might be a subtle mistake I’m missing.
The primitive value true
and “truthy” are not the same thing.
true
is a literal value, if you compare another value to it, it must be that value.
The second is any value that when coerced to a boolean is true. You still can’t compare it to true
unless you do the conversion.
const truthyValues = ["truthy value", true, true];
console.log(truthyValues.every((el) => el === true)); // false
console.log(truthyValues.every((el) => el)); // true
console.log(truthyValues.every((el) => Boolean(el) === true)); // true
console.log(truthyValues.every(Boolean)); // true
But the solution is hard-coded because of the regex that is used. You can skip forward to see the expected solution.
Thanks for the help. I just resolved it.