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

sierra giffin
sierra giffin
739 Points

Converting a string stored in a variable to upper case fails in a variety of methods that should work.

we were able to get a answer 3 different ways within the w3schools console, but team treehouse says its wrong each way

app.js
let firstName = "sierra";
let lastName = "giffin";
let role = "developer.toUpperCase()";
msg =  firstName + ' ' + lastName + ':' + role + ':';

4 Answers

Tim Oltman
Tim Oltman
7,730 Points

Hi Sierra,

As Mohammad is pointing out, you need to call the method toUpperCase() on a string. In your code it is simply part of the string and the browser won't recognize it as a function that needs to be performed.

Here is another way you might structure your code:

let firstName = "sierra";
let lastName = "giffin";
let role = "developer".toUpperCase();
msg =  firstName + ' ' + lastName + ':' + role;

You missed to declare your (msg) variable.

let msg = "the rest..";

@ Jelena Feliciano, I don't know if you mean me or not , but thanks any way.

let firstName = "sierra";
let lastName = "giffin";
let role = "developer";
let msg =  `${firstName} ${lastName}: ${role.toUpperCase()}`;

tried all 3 way you provided and it still dint't work. don't know how to make it work.

How come my code isn't working ? I solved the challenge before posting my solution.

sierra giffin
sierra giffin
739 Points

I believe that there is a bug, do you know how to get help from TTH staff?

Tim Oltman
Tim Oltman
7,730 Points

Hi Sierra,

I think I figured out your problem. You need to pay attention to the HINT. The spaces really matter here. There should be a space between the colon and the role.

The following code worked for me.

let firstName = "Tim";
let lastName = "Oltman";
let role = 'developer';
let msg = firstName + " " + lastName + ": " + role.toUpperCase();