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 The Solution

Joey Sudmeier
Joey Sudmeier
2,203 Points

Prompts not working for any of my practices; am I missing something?

I continue to have issues with my JavaScript, after I code and "view" the prompts and alerts don't seem to work. I'm sure I'm missing something in syntax but not sure what. Here is the full code I have for this assignment:

var nameFirst = prompt ("What is your name?"); var whereFrom = prompt ("Where are you from?"); var fullText = nameFirst.toLocalUpperCase() + " from " + whereFrom.toLocaleUpperCase(); var characterCount = full.length; alert "The string " + fullText + " is " + characterCount + " characters long.";

It is linked properly to the html file and document has been saved prior to viewing.

Thanks for your help!

2 Answers

Steven Parker
Steven Parker
231,007 Points

It looks like you have a few issues:

  • you wrote "toLocalUpperCase" instead of "toLocaleUpperCase"
  • you wrote "full.length" but you have no variable named "full" — perhaps you meant "fullText.length"?
  • you alert function call must be followed by parentheses () — the argument goes inside them

In future, to make posted code readable, please always use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:

Joey Sudmeier
Joey Sudmeier
2,203 Points

Hi Steven,

I renamed my variables just to be safe and failed to change the "full" one. Thank you for the detailed reply, you're correct and that fixed it. I think I've been overlooking the parentheses for alerts which has caused my problem with all of the js projects I've been working on...so that's very helpful.

Thanks again, Joey