(Windows/Linux users, whenever you see
cmd below or in upcoming lessons, use
ctrl if you need to.)
To open up your browser's console from Chrome, type
j (on Windows this is
i). From Firefox, type
k. From Safari, you'll first need to enable the Web Inspector; then you can press
Alternatively, open up Chrome and on any tab (even a blank one) right click and select
Inspect from the dropdown. From there, select the
With your console open, type
and press "enter".
What was that?
(Note: You might see
undefined in the console after you click "OK" — this is normal, and nothing to worry about.)
A large part of programming is experimentation — we come up with a hypothesis (how we think something should work) and test it with code.
In console, enter
alert('Hello, world!') (with single quotes instead of the double quotes above). What happened? It should have worked the same way as before.
But now how about
alert()-ing with a few phrases of your own. Experiment! Try things that you aren't sure will work — it's okay if they don't!