MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/qmpsx2/the_worst_iseven/
r/badcode • u/jameswdunne • Nov 04 '21
11 comments sorted by
3
While these are shockingly bad, I'm still impressed that this is more functional than what the past developers on my clients we site wrote.
1 u/jameswdunne Nov 07 '21 Tell us more! 2 u/kristallnachte Nov 07 '21 Maybe one day.A recent one I'm fighting with is one where they included the entire jQuery library as the second line in a 200 line file.All so they could use $ and $.get a handful of times.
1
Tell us more!
2 u/kristallnachte Nov 07 '21 Maybe one day.A recent one I'm fighting with is one where they included the entire jQuery library as the second line in a 200 line file.All so they could use $ and $.get a handful of times.
2
Maybe one day.
A recent one I'm fighting with is one where they included the entire jQuery library as the second line in a 200 line file.
All so they could use $ and $.get a handful of times.
10
You clearly haven't mastered real coding with if statements
7
Image Transcription: Code
function isEven(x) { if ((x >>> 0).toString(2)[(x >>> 0).toString(2).length - 1] == 0) { return true; } else { return false; } }
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
Sure, bitwise operations are curious, but have you tried regular expressions?
function isEven(x) { return !/\./.test(x/2); }
Right? Obviously should be
function isEven(x) {
if ((x >>> 0).toString(2)[(x >>> 0).toString(2).length - 1] == 0) { return true; } return false; }
I can make it even worse:
function isEven(x) { if ((x >>> 0).toString(2)[(x >>> 0).toString(2).length - 1] == 0) { return true; }if ((x >>> 0).toString(2)[(x >>> 0).toString(2).length - 1] == 1) { return false; } }
Who needs else statements am I right?
https://github.com/JesseBoogaard/isOddOrEven-collection/blob/master/JS/ovenOrEdd.js
My entry
What on earth is >>>? Is it the non-automatic-typecasting version of >? Is it the ultra bitshift operator?
1 u/MattiDragon Nov 08 '21 Pretty sure >> would put ones at the end on negative numbers. >>> always fills with zeros making it superior in some situations
Pretty sure >> would put ones at the end on negative numbers. >>> always fills with zeros making it superior in some situations
3
u/kristallnachte Nov 07 '21
While these are shockingly bad, I'm still impressed that this is more functional than what the past developers on my clients we site wrote.
10
u/404invalid-user Nov 04 '21
You clearly haven't mastered real coding with if statements
7
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Nov 04 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
3
u/--var Nov 04 '21
Sure, bitwise operations are curious, but have you tried regular expressions?
2
u/kostaslamprou Nov 04 '21
Right? Obviously should be
if ((x >>> 0).toString(2)[(x >>> 0).toString(2).length - 1] == 0) { return true; } return false; }
3
u/ImplementNational165 Nov 04 '21
I can make it even worse:
function isEven(x) { if ((x >>> 0).toString(2)[(x >>> 0).toString(2).length - 1] == 0) { return true; }if ((x >>> 0).toString(2)[(x >>> 0).toString(2).length - 1] == 1) { return false; } }
Who needs else statements am I right?
1
u/v_maria Nov 04 '21
https://github.com/JesseBoogaard/isOddOrEven-collection/blob/master/JS/ovenOrEdd.js
My entry
1
u/SuitableDragonfly Nov 07 '21
What on earth is >>>? Is it the non-automatic-typecasting version of >? Is it the ultra bitshift operator?