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 trialHeriberto Perez
1,298 PointsUse the prompt() method to ask the user "What day is it?" and store the result in the answer variable. I am stuck with e
I wrote:
var answer prompt ("What is your name?"); var answer = prompt("What is your name"); alert(answer);
var answer
prompt ("What day is it");
var answer = prompt ("What day is it");
alert(answer);
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="scripts.js"></script>
</body>
</html>
4 Answers
Salman Akram
Courses Plus Student 40,065 PointsHi Heriberto,
You have missed question ? inside prompt message.
var answer = prompt ("What day is it?");
Heriberto Perez
1,298 PointsThank you so much! i didn't realize it
Salman Akram
Courses Plus Student 40,065 PointsGreat, it happened to us all the times.
Happy Coding! :)
P.S: Please make sure to mark best answer that solve your question if possible and also prevent others from similar mistakes.
Michelle de Haan-Pitman
2,310 PointsSomething else which should be causing a problem is declaring the answer variable twice. You either need to rename the second one or if you want to reuse the answer variable then delete the second var keyword.
Hope this helps a little.
Shruti Kapoor
2,388 Pointsvar answer;
prompt("What day is it?" );
answer = prompt("What day is it?" );
document.write (answer);
Tonye Jack
Full Stack JavaScript Techdegree Student 12,469 Pointsvar answer;
//prompt("What day is it?" ); //No need to prompt twice
answer = prompt("What day is it?" );
document.write (answer);