Codeloft
0 0 XP

Variables and the console

6 min 20 XP + 10 for no hints

A variable stores a value under a name. let creates one: let firstName = "Sam";. Text values, called strings, go inside quotes.

console.log() prints a value to the console, the developer's notepad. Join text with +: console.log("Hello, " + firstName);

JavaScript doesn't run as you type. Press Run (or Ctrl + Enter) and watch the Console tab.

Example
let city = "Lisbon";
let year = 2026;
console.log("I'm visiting " + city + " in " + year);
Names are case-sensitive: firstName and firstname are two different variables.

Your tasks

0 of 2 done
  1. Store your name in firstName
  2. Print a message that includes "Hello" and your name

Quick check

What does console.log("2" + "2") print?

hello.jsPress Run or Ctrl + Enter
Press Run to see what your code prints.