Here uses let ,there uses const ,why


let Airplane={};
module.exports = {
myAirplane :“CloudJet”,
displayAirplane: function(){
return this.myAirplane;

const Airplane=require(’./2-airplane.js’);

hi everyone
my question is the same variable Airplane ,which is used in the same programme ,but at html ,we use ‘let’,
but at js ,we use ‘const’,why ?


deciding if you want to use let or const is a decision made by the programmer, okay, maybe not yet in the codecademy exercises, but you are still learning.

const (which is short for constant) variable can’t be change/updated/re-assigned, so if you do:

const example = "hello world"
example = "this will give an error"

with other words, when we define Airplane variable on line 1, we know it still needs changing, so we use let (let does allow for the variable to get re-assigned)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.