Truthy/Falsy Flashcards

0
Q

Truthy/Falsy:

function testNumber(x) {
   if(!x) {
      console.log("no number entered");
   }
   ...

When will this test fail?

A

When x==0 (falsy) the test will if statement will pass and log that no number was entered.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

Truthy/Falsy:

Which values are considered falsy in JavaScript?

A

False, NaN, undefined, -0, 0, “”, null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly