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 trialVictor A Hernandez
1,957 PointsBummer: Make sure you're concatenating `: ` to `lastName` and `role`.
I am stuck in this step, some body help me please.!
let firstName="Victor,";
let lastName="Hernandez,";
let role = 'developer';
let msg= "Victor," + " " + "Hernandez," + ":"+ 'developer' + " . " ;
console.log(msg);
6 Answers
Cameron Childres
11,820 PointsHi Victor,
Looks like I missed your previous replies. Let's take a look at your code from Nov 17:
let firstName= "Victor";
let lastName= "Hernandez";
let role = 'developer';
let msg= firstName+' '+lastName+':'+role+'.'+role.toUpperCase();
// produces "Victor Hernandez:developer.DEVELOPER"
The beginning looks great, you've got the space added between firstName and lastName and a colon following it. You need to keep with that, explicitly adding exactly what you want in the string. Currently you have the role variable in there twice, you haven't added a space, and there's a period where there shouldn't be one.
To make it match the string "Victor Hernandez: DEVELOPER" you can do as follows:
let msg= firstName+' '+lastName+':'+' '+role.toUpperCase();
// produces "Victor Hernandez: DEVELOPER"
Notice that after concatenating the colon to the string I added a space, just like between the first two words. I've only used the role variable once, with the toUpperCase() method to capitalize it.
As always with code there are a number of ways to accomplish the same thing. One way to simplify it would be to combine the colon and space between one set of quotes:
let msg= firstName+' '+lastName+': '+role.toUpperCase();
// produces "Victor Hernandez: DEVELOPER"
Cameron Childres
11,820 PointsHi Victor,
The challenge wants you to assign your name to the variables and then use those variables to build a message by concatenating strings.
In your first two lines you've set the variables appropriately as strings but the comma is unnecessary. If you remove the comma after Victor and Hernandez then when you use those variables later they will accurately represent your first and last name.
The message should be built from the variables. Instead of typing out your name again you'll type firstName and lastName. For example:
let firstName= "Victor";
let lastName= "Hernandez";
let msg = firstName + " " + lastName;
// builds a string "Victor Hernandez" and stores it in the variable msg
Lastly you'll want to pay attention to punctuation and spacing when you concatenate the strings in the message. Since the variables don't include spacing/punctuation we add in these strings manually, like the space in between your first and last name in my above example.
If I run the code in your post it produces this for msg:
"Victor, Hernandez,:developer . "
The goal is to match this format exactly:
"Victor Hernandez: developer"
Pay careful attention to the spacing -- one space between firstName and lastName and a colon and a space between lastName and role.
I hope this helps! Let me know if you have any questions.
Victor A Hernandez
1,957 PointsThank you Cameron, I appreciate your answer and your time. This information help me.
Victor A Hernandez
1,957 Pointslet firstName= "Victor"; let lastName= "Hernandez"; let role = 'developer'; let msg= firstName+' '+lastName+':'+role+'.'+role.toUpperCase();
Victor A Hernandez
1,957 PointsI still have the same problem. I has not been able to continue my regular study because this problem.Can somebody help me to pass this problem?
Victor A Hernandez
1,957 PointsI have not received solution to my homework, then I decided to start learning to code with Python. Where is the teacher that can not help?
Victor A Hernandez
1,957 PointsThank Cameron, the cod works very well.