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 trial

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".