Intro to JavaScript

Using JavaScript Code

🙋 Need help? Ask an expert now!

When using JavaScript with HTML, the JavaScript code can be placed in a <script> tag in the header or as a <script> tag in the body (not recommended). An alternative will be to linking it to a <script> tag in the header as an external file. This is highly recommended as some javascript code can go beyond 100-200 lines. These files usually have a .js extension and will get cached by the browser. The code below contains a simple program that print "Hello" to the console in the terminal.

The console is part of the browser and is a tool used for debugging JavaScript. However, as the sample code has its own console, whatever you print on the console will show up there. The method .log() outputs a message to the console. Feel free to change "Hello" and print something else!

Edit Me on GitHub!

Application Question

Which of the following console.log() statements return "Welcome!"?