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 Change the Value in a Variable

I didn't get anything from this lesson. ((((

I didn't get anything from this lesson. (((( I've read transcripts? I've watched the video and didnt't det it.

1 Answer

Alzubair Alshehhi
Alzubair Alshehhi
2,792 Points

Think about it this way, Variables are like boxes to store information in them. Say we have a box that has 0 apples in it.

var box = 0

Now we would like to tell the computer to put 10 apples in the box. Then we could say.

box = 10

What if we wanted to add to that box 5 more apples? Well we could do the math our self and write.

box = 15

Or since we know that the box contains 10 apples already, we could simply add 5 and let it do the math. So we are simply saying, add the contents of box + 5 .

box = box + 5

And that can be shortened to.

box += 5

Which means the exact same thing, just a shorter way to write it. Does this help?

Thank you very much for your answer!!It was very helpful!!)))