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 trialAnna Moreno
4,331 PointsCan't Upper Case my string
I can't done that my finale concatenation have a upper case word like this one: "Carlos Salgado: DEVELOPER".
let firstName = "Anna";
let lastName = "Moreno";
let role = 'developer';
let role = role.toUpperCase();
let msg = firstName + ' ' + lastName + ':' + role + '.';
2 Answers
Rabin Gharti Magar
Front End Web Development Techdegree Graduate 20,928 PointsHey Anna Moreno,
You need to create a new variable because when you try to modify role
variable it gives you an error message saying The original string stored in the role should not be modified
.
Here, I have created a new variable named roleUpper
and inside this, I stored role
and applied a toUpperCase()
method to capitalize the string. And inside msg
remove the role
var and replace it by roleUpper
.
Here's the final code:
let firstName = "Anna";
let lastName = "Moreno";
let role = 'developer';
let roleUpper = role.toUpperCase();
let msg = firstName + ' ' + lastName + ': ' + roleUpper;
Hope this helps!
Unsubscribed User
Front End Web Development Techdegree Student 33,900 PointsHi Anna,
the method does not work because you used a "let" before "role".
This creates the error "Uncaught SyntaxError: Identifier 'role' has already been declared".
You only use "let" when you declare the variable. Thereafter only use the name of the variable.
So just delete the "let" and you will be fine...
Makes sense?
Happy coding, Nils
PS: If this helped you and answered your question, you can mark my answer as "best answer" so other people see directly that the question was answered.
Anna Moreno
4,331 PointsHi Nils,
thank you for the answer. I understood what you mentioned. But actually it didn't help with the exercise, I can't understand why. :( The exercise take as good one the rabin answer.