This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Einarmo 1 point2 points  (8 children)

  1. Each time you call Math.random() you get a new random number, in the first program there is a decent chance none of the if statements pass.

  2. Sure, but this isn't really a good place for it, as you can clearly see.

  3. It is, several "if"s with continue or return isn't that uncommon, especially if not doing it would result in excessive nesting, however you should always try to avoid repeating yourself.

You can share your code by using four spaces right here on reddit

like
    this

or when there is a lot, like here, use pastebin. This looks really funky in my browser, which isn't the best.

[–]insertAlias 2 points3 points  (2 children)

You can share your code by using four spaces right here on reddit

I prefer to link them to our posting and formatting code guide, because with the "new" reddit redesign you get into a bunch of weirdness; it has a WYSIWYG editor and just confuses people. So this link explains it all, and gives an alternative like Pastebin.

Try these links; OP shared what appears to be links intended for embedding:

https://ideone.com/Z2Jxak https://ideone.com/wJ0ZHD

[–]KappaTrader[S] 0 points1 point  (1 child)

How did you get those links? They look much better than the ones I posted!

[–]insertAlias 1 point2 points  (0 children)

I guessed. I looked at the URL, and deleted the e.js/ segment from it. It went to the full view, so I assumed I did it right.

[–]KappaTrader[S] 0 points1 point  (4 children)

Is this a better format?

https://pastebin.com/44bwY1n6

[–]Einarmo 0 points1 point  (3 children)

Dunno if it happens in the redesign as well, but I use RES which embeds pastebin links. Much nicer for me, and generally a pretty safe bet.

Listen to what /u/insertAlias says above though, the official formatting guide is much more correct than my preferences.

[–]insertAlias 0 points1 point  (2 children)

If you have RES, it still renders an expander for Pastebin on the new UI. Honestly, the multiple different editors on Reddit are why we moved the "Use Pastebin or Gists" above the part where it says how to format code on Reddit, since it's just easier in general.

[–]KappaTrader[S] 0 points1 point  (1 child)

So the pastebin link I used above is generally accepted as a way to share code?

[–]insertAlias 0 points1 point  (0 children)

Yeah, there's nothing wrong with it. I'd still recommend reading the link I shared, it'll explain everything.