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

Stamos Bolovinos
Stamos Bolovinos
4,320 Points

IE alerts with 'undefined', Chrome fine

If I use IE, it prompts with a prefilled 'undefined', which must be overwritten with the value you want to enter. In Chrome, it does alert with an empty alert box, as it should.

How to make IE behave like Chrome, and the alert box to have no initial value?

I tried with initializing the variable to an empty string or null, but doesn't help. var visitorName = ""; console.log(typeof visitorName); visitorName = prompt("What is your name?");

1 Answer

Stamos Bolovinos
Stamos Bolovinos
4,320 Points

Found the answer myself, for IE, the code must be

var visitorName = prompt("What is your name?","");