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

Does anyone can help me with Challenge Task 2 out of 3 on java basics that wants you to combine first n last name

app.js
let firstName = ('Alana');
let lastName = ('Warson');
let role = 'developer';
const msg = "Alana"
const msg = "Warson"
const sentance = phrase1 + phrase2 + '.'; 

2 Answers

Hi Alana!

I think the main objective of these challenges is to demonstrate you know how and why to make use of variables.

This passes step one:

let firstName = 'Alana';
let lastName = 'Warson';
let role = 'developer';

This passes step two:

let firstName = 'Alana';
let lastName = 'Warson';
let role = 'developer';

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

This passes step three:

let firstName = 'Alana';
let lastName = 'Warson';
let role = 'developer';

let msg = firstName + " " + lastName + ": " + role.toUpperCase();

By the way, you can use const instead of let, too (or var even), but let or const are better (just remember that let has limited scope and const is immutable).

More info:

https://www.w3schools.com/js/js_es6.asp

I hope that helps.

Stay safe and happy coding!

Peter, thank you so much for your help! I was on the right track for second part but forgot the last command. Again, thank you for your extra finish.

Alexander Besse
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Besse
Full Stack JavaScript Techdegree Graduate 35,115 Points

Hi Alana Warson!

Here are the directions for the task:

Below role, create a new variable named msg that combines the firstName, lastName, and role variables to create a string like "Carlos Salgado: developer".

HINT: Pay close attention to the spaces in the string.

The task is asking you to make one new variable, name it msg, and then add firstName, lastName, and role together so they follow the format: firstName + lastName: role.

To point you in the right direction, I would remove the two msg variables and the sentence variable that you currently have. Also, remove the () from around the firstName and lastName strings. This will give you a clean working area to start in. Then make your new variable named msg and set it equal to the three strings put together (in the right format). Remember to pay attention to spacing, and where the ':' goes!

I hope that helps. Feel free to reach out on this post again if you're still stuck.

Happy coding!

Thank you so much