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 trialDevon Deason
7,061 PointsWhy don't i get two alert boxes?
I'm only getting the hello alert box, why?
var message = "Hello!";
alert(message);
message = "welcome to Javascript basics";
alert(message);
5 Answers
jason chan
31,009 PointsMight be IT issue then. Please clear browser history or try different browser to see if it works. cache is the greatest enemy in the IT world.
Devon Deason
7,061 PointsCleared the cache and we're just fine now! Thanks! Damn you cache!!! :)
Jason Anders
Treehouse Moderator 145,860 PointsHey Devon,
Your code is correct, and it runs fine when I run it in my console. I got the first "Hello" ... hit enter and got the second "welcome to Javascript basics".
So, I'm not sure why it isn't working for you. Everything is fine!
:)
Aaron HARPT
19,845 PointsYou need to change your variable names from the same thing.
Donald Brunais
8,895 PointsIt could also be browser thing. In chrome if you have multiple alerts it will give you a check box to ignore anymore alerts that pop up.
ammonquackenbush
3,867 PointsJust do not click the check box referenced above by Donald Brunais and you should be fine.
jason chan
31,009 Pointsvariables are like batteries you store information in those batteries. But you stored message a second time so that battery is storing something new.
Jason Anders
Treehouse Moderator 145,860 PointsAaron HARPT & jason chan you are correct, but where Devon is in the instructions, he is told to do it exactly like that. Dave is teaching how you can overwrite variables (in the video) and uses the two separate alert
boxes to illustrate that. So, Devon should be getting 2 boxes with the 2 different messages.
:)
idan shimon
Courses Plus Student 135 Pointsidan shimon
Courses Plus Student 135 Pointsjavascript interpret the code and running it line by line, syntax commands are executed one after another meaning one command only executes if and only if the previous command finished.
alert - native method to create a window object, when you type alert the browser creates a new window object for and place the argument string in it to display.
the javascript interpreter is waiting for the browser to return from its action to continue interpret the rest of your code.