Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@Mitiko Most languages dont allow less than and more than (and they dont allow the && operator, certainly) statements in switch/ case statements. Switch/ case has a very specific use, language agnostically, and it isnt checking for a range of values. But it would work in this case, thanks to js.
-
Mitiko63558y@AlgoRythm Isn't that "for" for?
And wasn't it just faster easier and cleaner to write it 3 times? -
@itsdaniel0 @Mitiko I read "foreach" instead of "for", sorry. I'm not too sure why I didn't use a for loop. Does it make any difference?
-
@Mitiko Ultimately, it comes down to preference. Although I'm sure benchmarks will recommend one over the other
-
@itsdaniel0 I agree on longer loops with 50+ lines inside but this loop only has two lines: the operation and iteration. It's more simple in my eyes, and I would argue, more readable.
-
620hun83708yIf it's JS just pass it through Closure Compiler and see if it changes it. If it doesn't, then this is the simplest form 😛
-
zerberus68y...it was this moment as you write your own code instead of copying it from anywhere 😂
-
@magicMirror Why would I use somebody else's code for something which I accomplished in 39 generously spaced lines?
Proud moment today when I actually made an hsv to rgb conversion algorithm by following a formula rather than copying code from stack overflow
undefined