Check this out!

Here’s some code I posted on Forrst a while back.

There’s an error with this code. Where it says

    $(this).html()



I meant to write

    $(this).html(html)



Four little characters – but they make the difference between this snippet working, and failing miserably. It was an honest mistake, and it’s fixed now – but nobody picked up on it. That code sat there for weeks. There’s a worse aspect to this, though. Check this out. Here’s a screenshot, in case that disappears:

Someone has taken my code, pasted it into a forum, and asked people to refactor it. This is actually the second version of this that I’ve found – unfortunately the other one was deleted from the original site, and unfortunately the Google Cache too. The original question was worded exactly the same, posted on a different forum, and had an answer that said “The line $(this).html() seems unnecessary.” – which, I guess, is technically correct. Sure enough, someone posted a comment on the original Forrst page shortly after, omitting that line:

That doesn’t work – that’s even worse than my original code! This guy has taken my code, copied it into a forum, asked whether it can be refactored, and then come back with his “refactored” code. That’s awful. I bet this happens all over the show. Have any of you seen this?

However – none of this actually matters. As it turns out, I didn’t look closely enough. There’s another error.

This is one of my problems with sharing code online – you can publish any old shit and people will love it. In this case, the premise is there – but it’s still wrong. If you’re sharing code online, turns out you don’t have to make it work to get a whole bunch of likes. Is that bad? I would certainly make the case that the concept of how this code works is really important – looking at the way it loops. In a sense, reading it as pseudocode is probably a pretty good idea.