LESSON 01 OF 10
Getting Started
Make your first program and connect JavaScript to HTML.
Before this lesson: start with basic HTML and a browser. No installation or account is needed.
The idea
JavaScript runs instructions. In a browser it can respond to input and update a page. HTML supplies structure and CSS supplies appearance. Java and JavaScript are separate languages.
At a glance
| Syntax | Purpose |
|---|---|
console.log() | Print a value for inspection |
// comment | Explain a line without running it |
defer | Run an external classic script after parsing |
Try it yourself
Create a folder with index.html and script.js. Put <script src="script.js" defer></script> inside the HTML head. The defer attribute lets an external classic script run after HTML parsing. Open the page, then open Developer Tools → Console to see console.log output. The editor below already supplies a page and captures your logs.
Ready. Run the example to open its preview.
Console output
Not run yet.
Page preview
Expected result
Hello, JavaScript! 10
What to watch for
Statements execute in order. Strings use matching quotes; numbers do not need quotes. Names are case sensitive. A semicolon can end a statement.
Your turn
Print your name, then print the result of 8 * 3.
Show one solution
console.log("Nicole");
console.log(8 * 3);Check your understanding
Why is a log missing from the page?
console.log writes to the browser console. This guide captures it in an output area, but your ordinary HTML page will not do that automatically.