Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Quickstart Data Types and Variables Creating Variables

What else should I do?

What else should I do?

scripts.js
var myName = "Frank"
var myAge  = 29
var message = myName + myAge = "Frank is 29"
David Brener
David Brener
3,794 Points

Frank, Could you include a little more information on exactly what the issue is you may be struggling with? This will help clarify your question to the forum. Thanks!

2 Answers

Kyle Knapp
Kyle Knapp
21,526 Points

Hi Frank,

The challenge is expecting "Frank is 29", so you'll need to add " is " between myName and myAge. This is called concatenating strings. "Concatenating" just means "joining together". In Javascript, the simplest way to concatenate strings is to use the + sign, like so:

var message = myName + " is " + myAge;

You'll also need to remove = "Frank is 29", as re-assigning values to a variable in the same expression is not valid syntax. Also, assigning var message equal to "Frank is 29" would print "Frank is 29" every time you ran the program. In this case, we want the message to change when the values of myName and myAge change, so we should use the variables myName and myAge instead of hard-coded values.

David Brener
David Brener
3,794 Points

Frank, you can combine the variables to create your message using concatenation, as shown below.

var myName = "Frank"
var myAge = 29
var message = myName + " is " + myAge

when you run message in the console, it should display "Frank is 29".