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 trialfd dd
481 PointsSir, Did you say a wrong? You said value of 1st variable "Hello" will be gone but it exist.
Sir, Did you say a wrong? You said value of 1st variable "Hello" will be gone but it exist. It will be gone when you assign a new 2nd value with same var before commanding to print
3 Answers
Shashikant Chaudhary
5,365 PointsYes you're right ,but at the end the value which the variable message stores is the 2nd value i.e. "Welcome to Javascript Basics". So if you use the variable message in the later part of the code it will be having the 2nd value.
Hope it helps
Haroon Ahmed
5,173 PointsWhenever you update the value of a variable the previous value is overwritten and the variable has the new value which you have updated.
nirmalabasdeo
Python Development Techdegree Student 3,787 PointsHi Fd,
That is correct,when you update the value of the variable , the previous value is overwritten. In the exercise, both of the values were displayed because after each value, the function alert was called. If you removed the first alert function, you will see it displays only the second value of the message.
Nirmala
Jennifer Mitchell
Full Stack JavaScript Techdegree Student 3,917 PointsThe program still executes from top to bottom. At the beginning of the program, the variable contains the string "Hello!" so that is what appears in the first alert box. As the program continues to execute and the variable is changed, you will see the new value in a new alert box.