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 trialSTEVEN AGUILAR
6,336 PointsPrompt example in this video asks "What is your name?" Twice is my browser.
var question="What is your name?"; prompt(question);
var response=prompt(question); alert("Hi " + response + "!");
2 Answers
Aakash Srivastava
5,415 PointsHey friend STEVEN AGUILAR , it's because you are calling prompt(question)
twice .
First , you are calling it independently and then you are calling it again and assigning its response to the variable response .
Remember , you need to call it only once . Here is the improved code :
var question = "What is your name?";
var response = prompt(question); // First prompt(question) will be called then it's value will get assigned into response variable
alert("Hi " + response + "!");
Hope it helped :)
STEVEN AGUILAR
6,336 PointsThank you for pointing that out!
Aakash Srivastava
5,415 PointsYou are most welcome :)