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

How can I get my message to show on java console after entering in prompt dialog?

I get the following message when I entered my response in the prompt dialog. VM773:2 Uncaught ReferenceError: stingToShout is not defined at <anonymous>:2:15

2 Answers

So, as I suspected, you have a typo. You declare stringToShout, but then when you assign shout, you are setting it to stingToShout.toUpperCase(). You're missing the 'r' in 'string'.

This next bit won't necessarily affect your code, but if you're just logging a string to the console like you're doing in your code, you don't have to have the extra variables. You can do this in less lines like so:

const stringToShout = prompt("What do you want to shout?");
console.log(`<The message to shout is: ${stringToShout.toUpperCase()}!!>`;

In fact, you could even do this:

console.log(`<The message to shout is: ${prompt("What do you want to shout?").toUpperCase()}!!>`);

Yeah! I got it. Thank you so much. This is not easy and it sure takes a lot longer to understand than it would appear.

Without seeing your code, it's hard to say for certain what's happening, but I would double check your variable names. From your error, it looks like you're doing your console.log on line 2, but it can't find a variable named "stingToShout". The 2 most common reasons I could think of for that is that you either didn't assign a variable to the prompt, or the variable that is assigned the value from the prompt has a different name (like possible "stringToShout"?). If it's neither of those issues, post your code so we can see what you're doing, and we may be able to provide a better answer.

Thank you. I will double check my work.

Sadly, it is still not working for me. I get the prompt dialog, but no display of the message. Here is my code.

const stringToShout = prompt("What do you want to shout?");

const shout = stingToShout.toUpperCase();

const shoutMessage = <The message to shout is: ${shout}!!>

console.log(shoutMessage);