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 trialShira Lotan
3,040 PointsDate type and variables
Use the alert() function to display the contents of the message variable in a dialogue window.
How can I solve this?
var myName = "Shira";
var myAge = 33;
var message = myName + ' is ' + myAge;
alert ("message");
1 Answer
Charles Badger
18,189 Pointsremove the quotes from "message" in your alert.
When you type
alert("message");
you're telling JavaScript to display the string "message" in an alert.
If you were to use
alert(message);
you would be telling JavaScript to display the contents of the message variable in an alert.
Alex Koumparos
Python Development Techdegree Student 36,887 PointsAlex Koumparos
Python Development Techdegree Student 36,887 PointsHi Charles,
Just an FYI, since your comment correctly answers the question, I've converted it into an answer.
I also applied syntax highlighting to your code examples. It's especially helpful here as it draws attention to the fact that
"message"
andmessage
are different types.Cheers
Alex