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) Storing and Tracking Information with Variables Capturing Visitor Input

Robert Moss
Robert Moss
1,797 Points

What's wrong with the code?

Are there any mistakes in this line of code?

var visitorName = prompt('What is your name');

I can't tell what's wrong with it. The prompt box is not popping up when I press on webpage view. I have made sure I have saved everything and that is not the problem.

Gina Scalpone
Gina Scalpone
21,330 Points

There's nothing wrong with this code. What does the rest of your code look like?

Robert Moss
Robert Moss
1,797 Points

The entire code was just:

var visitorName = prompt('What is your name');

alert(visitorName);

I was going through the video and my code was not having the same effect on the webpage as the instructors. It is word for word what he wrote.

I have noticed this happen a few times, usually the first lesson when I start a session on Treehouse. I will be writing really basic code verbatim for what the instructor is writing and it will have no effect on the webpage when I view it.

Is it just me?

3 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Robert,

Your code works fine in my console. It may be a security setting in your browser that is preventing what is essentially a 'popup.' I use chrome, with pretty much only the default settings for Treehouse and haven't encountered any problems so far.

I'm not sure what to tell you... the code is correct.

:dizzy:

Justin Eaton
Justin Eaton
6,133 Points

Had the same problem in all browsers. Just checked my code with safari web inspector and it said there were also errors on lines 84 and 86 of the main.css file. I couldn't see any errors but I deleted and re-typed the * symbol on each line and suddenly the prompt started working. Glitch maybe?

Hayden LaBrie
Hayden LaBrie
2,913 Points

I had to refresh the page for it to pop up. Hopefully that works!

Phong Somlith
Phong Somlith
5,675 Points

I had this same issue and did what Hayden did. It works. Thanks Hayden!