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 (Retired) Making Decisions with Conditional Statements Introducing Conditional Statements

Carolyn Scudder
Carolyn Scudder
1,760 Points

Hello I'm trying to figure out why the prompt dialogue box hasn't been showing up for me during the last few tutorials

I'm not sure what I'm doing wrong, I've tried using the consol but maybe I'm not looking correctly? Here is the code I used for this time:

var answer = prompt('What programming language is the name of a gem?'); if ( answer === 'Ruby') { document.write(β€œ<p>That’s right!</p>”); }

any ideas? I'm currently using Google Chrome. Thanks!

in the console do receive an error message like the one below?

Uncaught SyntaxError: Unexpected token ILLEGAL

if so the issue might be this:

http://stackoverflow.com/questions/12719859/no-visible-cause-for-unexpected-token-illegal

it could be just how you posted the code into the question because there are formatting issues, but your code looks fine.

try deleting the if statement and see if the prompt will function. If so, you know the issue is in the if statement, and not the prompt.

4 Answers

var answer = prompt('What programming language is the name of a gem?');
if ( answer === 'Ruby') {
 document.write('That’s right!');
}

This should work, which is what you have. So, if it doesn't work then I have no idea how to fix it. Other than replacing your " " around That's right! with ' that's all I've changed, and I only changed it because the forum uses those special curved quotes for things and that gives errors in the console.

Carolyn Scudder
Carolyn Scudder
1,760 Points

You guys are the best! @Eric I didn't realize that the curly quotes were illegal and that's what the workspace kept doing (changing my quotes to curly quotes).

@Jacob, thanks for the link, that's where I found my answer to this issue! Apparently all I had to do was go to system preferences on my mac then Keyboard >Text(tab) uncheck use smart quotes and dashes (default was checked). Bam problem solved.

Thanks Again! :D

I'm glad we could help!! Happy coding!

I had the same issue. I will need to remember to escape apostrophe's!

I have the same issue as well, but I'm not using the curly quotes. I haven't been able to see prompts or alerts on the last few workspaces.