Practice: Predict the Output

Read short DOM scripts and predict exactly what each console.log will print. Reading code is half of writing code — train your eyes before your fingers.

Step 1 of 7

Read first, predict second

Before you write more DOM code, slow down and read some. Real engineers spend more time reading code (their own from a month ago, a teammate's, a library's) than writing fresh lines.

In this lesson you will see short DOM snippets. Your job: predict what console.log would print. No running the code — type your prediction into the blank that appears in the comment.

If you get it wrong, that is great information: the snippet is teaching you something about how textContent, value, attributes, and live element references actually behave.

Think of it this way: It is like reading a recipe before you cook. You imagine the dish in your head — what colour is it, how does it smell, would it match what you wanted? Skipping that step is how you end up with a sweet curry by accident.
Tip

Type your prediction exactly as it would appear in the browser console. Strings keep their original casing; numbers stay as numbers; null stays lowercase.