Many modern code editors, like Atom or Sublime Text, allow you to execute code directly in the text editor. If you Sublime Text, you can press Command-B on a Mac or Control-B on a Linux or Windows machine (B for “Build”) to see the output of your code at the bottom of the window.
If you are using Atom, you will have to download the Script package and execute your code with Command-I on a Mac or Control-I on a PC (I for… Ichabod).
This is great for doing some quick debugging. You can just shotgun some
console.logs around to verify that your code is working as expected.
If you want to quickly load some code into the browser, so that perhaps you can debug it in the console or see some output on the screen, then you're going to have to include your script inside of some HTML. It's really easy to make a dummy HTML file that only pulls in your code. Then it's just a matter of opening that HTML file with your browser.
Imagine a folder with your super important
fizzBuzz.js file. Simply create and
whatever.html file and add a script tag. Here’s what it could look like:
<html> <head> <script src="fizzBuzz.js"></script> </head> <body> <h1>This Is Unnecessary!</h1> </body> </html>
Now all your code is loaded up in the browser, any calls to
console.log should already be piled up in the console. Plus, you can now interact with any functions or objects you created right in the console.