← All topics

QUICK LOOKUP

Quick Reference

Find a concept, then return to its full lesson.

TopicUse it to
Getting StartedMake your first program and connect JavaScript to HTML.
Variables and Data TypesName values and distinguish text, numbers, and booleans.
Operators and StringsCalculate results, compare values, and build messages.
Conditions and DecisionsChoose a path with if, else, and comparisons.
Functions and ScopePackage steps, accept inputs, and return a result.
Arrays and LoopsStore a list and repeat work for each item.
Objects and Array MethodsDescribe related data and transform collections.
Changing the PageSelect HTML elements and change their content.
Events and User InputRespond to clicks and read a visitor’s input.
Debugging and a Mini ProjectRead errors and combine variables, functions, and events.

Common patterns

const name = "Nicole";
let count = 0;
if (count === 0) { console.log("Begin"); }
function double(value) { return value * 2; }
for (const item of [1, 2, 3]) { console.log(item); }
const title = document.querySelector("h1");
if (title) { title.textContent = "Hello"; }

Vocabulary

Expression: code that produces a value. Statement: an instruction. Callback: a function passed to other code to be called. Scope: where a name is available. DOM: the browser’s object representation of HTML. Event: a notification of an occurrence, such as a click.

When something breaks

  1. Read the first relevant console error and its line number.
  2. Check spelling and capitalization.
  3. Log the input values and their types.
  4. Check whether a DOM selection returned null.
  5. Make one small change and run again.