DEV Community

Discussion on: What's a recent frustrating bug you've had with a crazy simple solution?

Collapse
 
scottishross profile image
Ross Henderson

A procedure I had running was going backwards, and I simply had two swap two parameters around and the whole the worked as intended.

Collapse
 
jsn1nj4 profile image
Elliot Derhay

Backwards? Wow, that's definitely a new one on me.

Collapse
 
scottishross profile image
Ross Henderson

It was a stupid mistake by myself. Instead of it working out like 4 - 3 = 1, it was doing 3 - 4 = -1.

But it took me roughly 3 months to figure out it was a problem, i.e. when it went into production aha. My testing was showing correct values, but that's because I was faking the math correctly.

It was a learning experience :)

Thread Thread
 
jsn1nj4 profile image
Elliot Derhay • Edited

That reminds me of that post about things we always google. One of mine always seems to be the param order for the callback passed to Array.prototype.map().

Param order can definitely get you. But I'm now glad to have hints in both Atom and VS Code about what the next param is expected to be -- at least if the function is defined in the code, or is a native member of the language.

Thread Thread
 
nektro profile image
Meghan (she/her)

I don’t have a nice pneumonic to help but I realized one day that map, forEach, and a few others all have the same callback Parma order of value, index, array

Thread Thread
 
jsn1nj4 profile image
Elliot Derhay • Edited

I kept flipping index and value (and forgetting about array, honestly). But that order does make a lot more sense since the index and array aren't needed for everything.

Thanks for mentioning that by the way. I guess they would've done that for consistency and ease of use.