- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
If I had been given that task I would have made a result to percentage "map"/"dictionary". This would have allowed one to easily scan the relationship between the values and only have to write a single formatted alert. Overall would have been more readable to me.
Admin
The first question I have when seeing that logic is if the result is limited to one decimal place elsewhere.
Admin
those == comparisons on what looks like stringified floating point numbers are actually killing me. twice.
Admin
Am I eligible to be held for moderation?
Admin
Guess not. I failed.
Admin
Everything in moderation.
Admin
You're unregistered xD
Allowing an unregistered user to moderate one's website would be a serious WTF, and I don't think Remy Porter wants to be the WTF of the next Feature Article.
Admin
Plotting them seems to concur with this - it's straight or uniformly curved almost nowhere along the plot...
Admin
Setting aside who is held for moderation and why (and whether I will be too) ...
I like that we are comparing
result
which is logically a number regardless of its JavaScript datatype, to a decimal value with tenths expressed as a string. And using==
which invites all sorts of floating point not-quite-equals errors.In fact I'll bet that that page actually "works" for the majority of
result
values because all the==
tests always fail due to floating point conversion / non-rounding issues and noalert()
is displayed. But for some rare value, the one Gracie's friend got, thealert()
triggers and the page stops.I suppose another possible WTF we can't see here is that
results
might possibly conceivably actually be a stringly value as this code snip is executing. Which might not have quite the same format as the right side of the==
comparisons expect.Implicit type conversion and stringly everything is such an obstacle to correctness you'd almost think it (and much of the rest of JavaScript) was invented by somebody actively trying to sabotage the WWW.
Admin
That's what happens when you hire programmers who are bad at math.
Admin
They must really be needing teachers for maths and programming.
Admin
taking into account the old adage "Never attribute to malice that which is adequately explained by stupidity"
in this case I don't see how the relationship between "result" and "average" could possibly be explained by stupidity so I'm forced to the conclusion that malice is the only explanation
Admin
That the alert says "you must have a minimum average of 68.0 %" for values over 68% would put this in line for a place in this weekend's Error'd.
Admin
It's what happens when you hire admissions managers who are bad at math, and middle managers who force programmers to use this bad math even if the programmers know better.
Admin
Why, do you need a hug? ;-)
Admin
I think @King was saying that he wanted to be moderated. My advice is that there are surely some nice women somewhere in town who'd be willing to pay him a visit dressed in black PVC and moderate him.
Admin
It happens quite frequently enough already.
Admin
I think the spreadsheet idea is probably correct. Too many people are assuming that result is a number. It may as well be a row/column index where each cell gives the percentage. God knows what workflow is used to get that information.
Admin
If this is university code it's very likely that it was written by some first or second year student who had taken a javascript course and who was paid slightly more than minimum wage to convert a spreadsheet into a script.
(After working at universities for decades you see two types of code - core function code like HR and course assignments where they've either outsourced it or still have their own in-house team to maintain and extend what they have, and everything else where some student or staff member who doesn't have any real programming experience but has a few courses under their belt gets paid to slam something together. There's rarely anything in between.)
Admin
Well... If result is a floating point, then that code is horribly broken due to rounding errors. If it's all strings, it has a chance of being somewhat correct.
Admin
The "calculated average" seems to simulate what percentage of applicants did worse than the one whose results are shown. Someone who scored 0.9 is in the bottom 49% of applicants while someone who scored 2.5 is in the top 31.5% (100 - 68.5). Could these "results" be a skewed standard deviation (sd)?