cantstopthesignal@sh.itjust.works to Programmer Humor@lemmy.ml · 8 months agoThe code was very janky, but it workedi.imgflip.comimagemessage-square12fedilinkarrow-up14arrow-down10
arrow-up14arrow-down1imageThe code was very janky, but it workedi.imgflip.comcantstopthesignal@sh.itjust.works to Programmer Humor@lemmy.ml · 8 months agomessage-square12fedilink
minus-squareFiskFisk33@startrek.websitelinkfedilinkarrow-up1·edit-28 months ago is this really a feature not built into Java Script? x % 2 == 0
minus-squaremarcos@lemmy.worldlinkfedilinkarrow-up1·8 months ago(+x) % 2 == 0 If you forget for a second it’s Javascript, the language will turn back and bite you.
minus-squareFiskFisk33@startrek.websitelinkfedilinkarrow-up1·8 months agoI am not good friends with js, what did I miss?
minus-squaremarcos@lemmy.worldlinkfedilinkarrow-up1·8 months agoThis evaluates to NaN for some reason: '10' % 0 Since JS doesn’t really differentiate strings from numbers, except on the places it does, it makes sense to make sure you are working with numbers.
minus-squarecarpelbridgesyndrome@sh.itjust.workslinkfedilinkEnglisharrow-up1·8 months agoNot a JS dev either but ===. Not really sure what the (+x) is about
x % 2 == 0
If you forget for a second it’s Javascript, the language will turn back and bite you.
I am not good friends with js, what did I miss?
This evaluates to NaN for some reason:
Since JS doesn’t really differentiate strings from numbers, except on the places it does, it makes sense to make sure you are working with numbers.
Not a JS dev either but
===
.Not really sure what the
(+x)
is about