Which fix removes the bug?
const n = '7';
if (n === 7) {
run();
}
- Convert first:
Number(n) === 7in the test - Convert first:
String(n) === 7in the test - Change
const ntolet nbefore the test - Compare the value against
'7'with==
Strict equality never matches across types; convert the string to a number.
Play Problem Solving ▸