Diffrence between let and const

https://www.codecademy.com/courses/introduction-to-javascript/lessons/scope/exercises/global-scope

I noticed i can use both let or const and the program runs the same. I’m curious what the main differences are between them down the road.

let satellite = 'The Moon'; let galaxy = 'The Milky Way'; let stars = 'North Star'; const callMyNightSky = () => { return 'Night Sky: ' + satellite + ', ' + stars + ', and ' + galaxy; }; console.log(callMyNightSky());
const satellite = 'The Moon'; const galaxy = 'The Milky Way'; const stars = 'North Star'; const callMyNightSky = () => { return 'Night Sky: ' + satellite + ', ' + stars + ', and ' + galaxy; }; console.log(callMyNightSky());

constant variable (const) are constant, which means they can’t be changed/re-assigned

2 Likes

To add onto what Stetim said, here’s a good article explaining the difference.

1 Like