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 Basics Working with Strings Combine and Manipulate Strings

felix oyinloye
felix oyinloye
1,008 Points

Challenge Task 2 of 3 Below role, create a new variable named msg that combines the firstName, lastName and role variabl

what am i doing wrong

app.js
let firstName= "felix" ;

let lastName= "oyinloye";

let role = "developer";
var msg = firstName +   '  ' lastName ;

var msg= msg + role;

2 Answers

Dimitar Dimitrov
Dimitar Dimitrov
11,800 Points

You have skipped an + before lastName this is where the problem came from. You can check the ES 2015 Template Literals Course which do the same thing like string concatenation but in a more simpler and understandable way : https://teamtreehouse.com/library/basic-and-multiple-line-strings

let firstName= "felix" ;

let lastName= "oyinloye";

let role = "developer";
let msg = firstName + ' ' +  lastName + ':' + ' ' + role ;

This is how it should look with template literals:

let firstName= "felix" ;

let lastName= "oyinloye";
let role = "developer";

var msg = `${firstName} ${lastName}: ${role}`;