The code was very janky, but it worked

469 points · 34 comments · view on lemmy.world

34 Comments

FiskFisk33@startrek.website · 72 pts · 2y (27 replies)

better to go that way than this (note the weekly downloads)

Bumblefumble@lemm.ee · 55 pts · 2y (6 replies)

The best part is the dependency on the function is_odd.

jonwyattphillips@lemmy.ml · 44 pts · 2y (3 replies)

Which itself has a dependency of the function is_number.

FreshLight@sh.itjust.works · 4 pts · 2y (2 replies)

I can't

Klear@lemmy.world · 6 pts · 2y

Can't even or can't odd? If only there was a way to find out =/

cantstopthesignal@sh.itjust.works · 1 pts · 2y

The efficient use of memory is an efficient use of memory.

Caboose12000@lemmy.world · 4 pts · 2y

dear Lord lmfao

spez@sh.itjust.works · 2 pts · 2y

That is one deep rabbit hole.

hackris@lemmy.ml · 27 pts · 2y

If I was a JS programmer, I'd just write a bash script to download it every week for fun.

TonyTonyChopper@mander.xyz · 12 pts · 2y (15 replies)

300,000 every week... is this really a feature not built into Java Script?

FiskFisk33@startrek.website · 32 pts · 2y (13 replies)

is this really a feature not built into Java Script?

x % 2 == 0

marcos@lemmy.world · 27 pts · 2y (12 replies)
(+x) % 2 == 0

If you forget for a second it's Javascript, the language will turn back and bite you.

Kindness@lemmy.ml · 8 pts · 2y

(+x) % 2 === 0

FiskFisk33@startrek.website · 5 pts · 2y (6 replies)

I am not good friends with js, what did I miss?

marcos@lemmy.world · 7 pts · 2y (1 reply)

This 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.

FiskFisk33@startrek.website · 2 pts · 2y

Oh right that. I guess I was visualizing a scenario where you already checked for it being a number, such as a Number.isInteger(x)

also, that suprises me a lot, you'd think this is one of the places where it treats stuff as numbers

carpelbridgesyndrome@sh.itjust.works · 6 pts · 2y (3 replies)

Not a JS dev either but ===.

Not really sure what the (+x) is about

FiskFisk33@startrek.website · 1 pts · 2y (2 replies)

the remainder operator should return a number or a NaN right? do we actually need the triple here?

marcos@lemmy.world · 2 pts · 2y

Not really. But with JS it's better safe than sorry.

The GP's addition is unnecessary, but I fully support anyone that decides to do it.

affiliate@lemmy.world · 3 pts · 2y (3 replies)

what does the +x do.

marcos@lemmy.world · 6 pts · 2y (2 replies)

It makes sure x is a number.

affiliate@lemmy.world · 9 pts · 2y (1 reply)

what a wonderful and beautiful language. i’m so glad i asked

ArtVandelay@lemmy.world · 1 pts · 2y

And so wonderfully similar to the way that symbol is used in other languages as well. Gosh darn it I love JavaScript

Oszilloraptor@feddit.de · 8 pts · 2y

the is_even package does not provide much worth indeed because it simply negates is_odd and thereby all its benefit.

It's dependency is_odd on the other hand provides at least some additional checks (it also checks if the value is a valid integer below the max int value)

And while I would indeed see uses for such methods (especially with the other checks, no simple oneliners) in some cases, especially in testing: This is stuff you write yourself, throw it in a e.g. NumberUtils class and everything is fine. You do never depend on an external library for that. The benefit (not spending a few seconds to write it) does not outweigh any of the drawbacks that come with external libraries.

gigachad@feddit.de · 7 pts · 2y

Lmao

LostXOR@fedia.io · 3 pts · 2y
[ removed ]
cantstopthesignal@sh.itjust.works · 1 pts · 2y

True

crusa187@lemmy.ml · 51 pts · 2y (5 replies)

Damn bro I haven’t seen this meme format in over 20 years! Hopefully you don’t spend all that time debugging those proprietary functions ya goof

cantstopthesignal@sh.itjust.works · 29 pts · 2y (3 replies)

I'm just an old fart programming a neopixel as a hobby.

Asidonhopo@lemmy.world · 16 pts · 2y (2 replies)

Make it faster and jankier with precalculated lookup tables!

cantstopthesignal@sh.itjust.works · 13 pts · 2y (1 reply)

Make it even jankier with uncalculated variables.

LostXOR@fedia.io · 3 pts · 2y
[ removed ]
Hackerman_uwu@lemmy.world · 4 pts · 2y

Vintage meme indeed.

This dude always looked like a college aged Gregory House to me.

OldWoodFrame@lemm.ee · 10 pts · 2y

What a refreshing meme use. Makes me want a beer actually.

electricprism@lemmy.ml · 5 pts · 2y

The Power Of Math People

(those that know known those that do not know do not know, those that know wish they didn't know, those that don't know wish they knew)