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 trialkit prescott
2,774 Pointsjava script question
can someone remind me how to use the alert() function to display the contents of the 'message' variable in a dialogue window
const myName = "Kit";
let myAge = 39;
var message = "Kit" + "39";
var message = alert("Kit" + "39");
2 Answers
furkan
11,733 PointsYou have already stored those values into a variable called message. All you have to do is put the variable into the alert function and not as a string between quotation marks. Do this:
var myName = 'Kit';
var myAge = 39;
var message = myName + ' is ' + myAge;
alert(message);
kit prescott
2,774 Pointsthanks for your help