There are lots of times when you need to share code snippets, a good example is when you are troubleshooting a problem and need to ask for help. Instead of just explaining the problem you have to someone it's 1000 times easier to show them what the problem is.
If you are asking help with your code some people will just paste the code to you in an email or on a forum, this is a bit more helpful as I can take this code, run it and see if I can find out what's going wrong. But this relies on me having all the exact code that they're using, which might be lost while copy and pasting code from their editor, to an email, to my editor.
The best way of asking for help with your front-end code is to be able to share your exact code. But this is hard to do as most development problems should occur on your local machine with all the code on your local computer. The solution to this is to use web editor that allows you to share your code and the result, something like jsFiddle or CodePen.
- Go to jsFiddle or CodePen
- Hit run to test you can recreate the problem.
- Save to a URL
- Share the URL
This way the person you are sharing with can see the exact code you are using and can see the same problem you are trying to solve.
Here are some of the services you can use for free to share your code.