30 Days Of JavaScript

Day 1: Simple Types

Lesson 3: Variables

Constants are great but they are pretty inflexible, once you set it that's it forever.

Variables are the more flexible sibling to constants. You can create a variable, set it to a value and then later change that value to something new.

1let greeting = "hello";
4greeting = "hello world";

In the code above, we create a variable with the let keyword called greeting and set it to hello. We then log it out, change it to hello world and log it out again.

The first log will be hello and the second hello world. Note that when we change it to hello world we don't use the let keyword again. We only use let when we create the variable, if you were to put let in again you would get an error like: SyntaxError: Identifier 'greeting' has already been declared


Go Pro?

Upgrade to Pro for quizzes, tracked progress and a completion certificate for just $25 🚀

Want more developer tips, tricks and tools?
Then follow me:
FREE Coding Career Quick Start Guide 🚀
Discover the best way to learn to code, how to land a job and valuable resources to help your journey in this free 15 page value packed guide.
Looking to email me? You can get me on my first name at allthecode.co