... intended to show an input field when cost is null/undefined ... also shows the input when cost is zero.
It's safer to use a smarter null-checker, like Ramda's isNil() or equivalents in Underscore etc. (Or trivially roll your own). And use it always, as a matter of habit, because it's quicker than thinking about it on a case-by-case basis.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
The habit of using falsy checking has bitten me and my colleagues more than once.
... intended to show an input field when
cost
is null/undefined ... also shows the input whencost
is zero.It's safer to use a smarter null-checker, like Ramda's
isNil()
or equivalents in Underscore etc. (Or trivially roll your own). And use it always, as a matter of habit, because it's quicker than thinking about it on a case-by-case basis.