Skip to content
dreamcode
dreamcode
Map
Variables
Lesson 1 of 48
+15 XP on finish
JAVASCRIPT CLIMBSChapter 1 · JS Basics

Let and Const

In JavaScript, you declare variables using let or const. Use let if the value will change, and const for constants that stay the same.

Worked example

How it reads

  • let sky creates a re-assignable variable named sky
  • const stars creates a read-only constant variable stars
  • console.log() is JavaScript's way of printing output
Cloud tip: Always default to const unless you know the variable needs to be re-assigned.
index.js
JAVASCRIPT
real JavaScript, runs in your browser
Console
Run your code to see its output here.
YOUR TURN

Change mood to "curious" after it is declared, and add a const place = "the roof"; that is logged last. The output should be curious, 8, the roof.

Press Run to check your work.