What does const do?

I believe that making the variable constant keeps it the same value all throughout your code.

Yes, just like your opinion, I think the const makes some values unchanged while our program is running

Just one example of a simple use case:

const birthYear = 1975;
var myAge = 47;
var currentYear = 2022;

You see, your age changes, but the year you were born does not.

So…to add to it…you could do something like:

myAge = currentYear - birthYear;

return myAge;

The variable myAge would be assigned the result of currentYear - birthYear.

Privacy & Terms