The Environment: Where to Write Your Code
Text editors provide a comfortable environment, highlighting text, and even auto-correcting typos. This is done with the use of plugins. Just like your browser makes use of plugins such as an ad-blocker, so too does the text editor, which is incredibly useful for a developer.
Other such platforms similar to codepen are repl.it and jsbin.com. It’s worth giving them a look, but we won’t be building anything in this course.
As mentioned, in order to see immediate results, we’re going to use the console, which is a built-in feature of your web browser.
To pull up the console, right click on any website, selecting the “inspect element,” or just “inspect” option. This will pull up the HTML elements on the page, and that is how the website you’re viewing is structured! Notice that the top tabs are listed as follows: elements, console, sources, network, memory, application, security, and audits. We’re going to focus on the console tab, so give that a click. (Note: If you see red-colored text, don’t worry. Those are most likely errors that the developer of the website has to deal with, and nothing wrong on your end.) You should see a prompt, ‘>’, and a blinking cursor. It’s time to write your first line of code! In the console, type console.log(“Hello, world!”);.
The response: Hello, world!
For now, you don’t need to worry about strings—we’ll discuss them further in the next lesson—but the string is simply, “Hello, world!”, of which we passed into console.log();.
If you’re on a phone and want to see some action, you can type the following into the search bar:
You may recognize this from webpages asking you if you’re sure you want to close a tab or alerting you that your session expired. It is basically a message that you’d want a user to notice.
Stay tuned for the next lesson: variables, values, types, and operators.
Share with friends