edward-shen / MMM-MBTA

MagicMirror² module for the Massachusetts Bay Transportation Authority
MIT License
12 stars 4 forks source link

Fixed small ETA bug; Updated readme #10

Closed andywaplinger closed 6 years ago

edward-shen commented 6 years ago

Is it suppose to be double equals or triple equals?

andywaplinger commented 6 years ago

Double so that it can also catch undefined.

edward-shen commented 6 years ago
!undefined; // true
!null; // true
let a = undefined;
a == null; // true
a == undefined; // true

!minutes should work perfectly though.

andywaplinger commented 6 years ago

Ok, I believe I've got it. minutes is being converted to a boolean when putting ! in front. And at 0 minutes, !0 means not false which is true, and so it selects the first if statement.

By instead just catching null, it's comparing 0 to null, which is false, so it goes to the next statement 0 === 0.