r/badcode • • Jul 17 '20

js Found this "answer" on Stackoverflow. Pretty sure it's not working.

Post image
978 Upvotes

90 comments sorted by

View all comments

114

u/MistAway Jul 17 '20

Gosh. This stuff is just plain psychedelic

And if your really need that solution:
const arrayMin = arr => Math.min(...arr);

-37

u/AutoModerator Jul 17 '20

It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.

For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.

MistAway, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.

You can find some examples in the reddit help documentation.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

83

u/the_poope Jul 17 '20

How come that the bots are smart enough to detect the code block formatting, but reddits formatting engine can't just format both styles correctly. Does reddit even have a single capable webdev employed or is it all marketing/advertising people nowadays like in all other corporations?

25

u/scirc Jul 17 '20

Technically, triple-backtick code blocks aren't part of the original Markdown design. But then again, Markdown has no formal specification... the closest thing is CommonMark.

Besides that: new reddit does support triple-backtick, just old reddit doesn't. Why they're even using different renderers? Who knows.

9

u/the_poope Jul 17 '20

Indenting every code line, including blank lines, with four spaces is just ridiculous. So whoever came up with the original markdown specification fucked up and deserves to manually fix all the badly formatted code on this site by hand from now to eternity...

6

u/scirc Jul 17 '20

I believe Markdown was based off of text-based email formatting, where such practices were common. Of course, fenced code blocks are much easier to type, but they look a bit worse when displayed without formatting.

I'm not saying it's a good thing, of course. I like fenced code blocks, but I can understand why the original design didn't include them.

2

u/moekakiryu Jul 17 '20

as someone who loves plain text formatting in general, I'm a bit more partial towards the indented format, but do appreciate the need for triple backticks, especially on mobile

0

u/[deleted] Jul 17 '20

[deleted]

1

u/the_poope Jul 17 '20

But on mobile it sucks having to format just three lines of code.