Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics Storing and Tracking Information with Variables Update the Value of a Variable

JAE IN KIM
seal-mask
.a{fill-rule:evenodd;}techdegree
JAE IN KIM
Front End Web Development Techdegree Student 6,794 Points

I don't know why I need to switch const to var..those two have different name for tag.

const points = 100; const bonusPts = 50;

points += bonusPts; console.log(points);

app.js
const points = 100;
const bonusPts = 50;

points += bonusPts;
console.log(points);

3 Answers

Fran ADP
Fran ADP
6,304 Points

The const variable is for not changing things, it is constant, and var is for variables, things that change.

Mark Sebeck
MOD
Mark Sebeck
Treehouse Moderator 37,905 Points

The value of a 'const' can not be changed. So in your example bonusPts could be a 'const' but since you are changing the value of points it can not be a 'const'. BTW the new standard in JavaScript is to use 'let' instead of 'var'. Hope this clears up the confusion.

JAE IN KIM
seal-mask
.a{fill-rule:evenodd;}techdegree
JAE IN KIM
Front End Web Development Techdegree Student 6,794 Points

yesterday when I read your comment, I didn't get it......but today morning I just got 'ah' moment! Now I remember that 'const' is not for sport scoring system as you said ' the value of const can not be changed. thank you!

Casey Peterson
Casey Peterson
1,865 Points

Is anybody on to help me figure out how the this is supposed to look?

Mark Sebeck
Mark Sebeck
Treehouse Moderator 37,905 Points

You just need to chance the const to a var or let. Constants can't change just variables. let is the new javascript standard for variables but var still works.