JavaScript can remember values, notice events, and update a page. Start small: name a message, listen for a click, then repeat a task.
Three lessons · about 21 minutes0 of 3 complete
LESSON 1 · VALUES & VARIABLES
Give a value a name.
A variable lets you refer to a value by name. Use const when you do not plan to assign a different value to that name. Strings hold text, numbers hold numeric values, and the browser console can show either.
Good names help:lessonsFinished gives more context than a vague name like x.
Quick check: which keyword creates a value you will not reassign?
A small step counts.
LESSON 2 · EVENTS & THE PAGE
Respond to a click.
An event listener waits for an event such as a click. When the event happens, JavaScript runs the function you provide. Here, the function changes the message in the page.