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 triallance leach
2,402 Pointsuse the prompt()in Javascript challenge 2 of 3
I dont see what i am doing wrong. Please help I have spent a hour on this and odnt see any mistakes.
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
Alexandra Edwards
4,686 PointsYou've created the variable answer and now need to create a prompt which stores the result in that variable, answer. The prompt() method will create a dialog box, so you don't need the alert() method and you've already declared the variable answer once, so you don't need to have a second variable of answer. For challenge 2 of 3 you actually have the answer on one of your lines of code and just need to delete the rest! :)
var answer
prompt ("what day is it?");
Var answer = prompt ("what day is it?"); // hint, hint -- but with a lower case 'v'
alert(answer);
Let me know if my not-so-subtle hint helps, or if you need more help! :)
Yuval Blass
18,134 PointsHi there ?,
Let's walk together through the challenge:
- "Create a variable named answer but don't put a value in it yet." - You did it right.
var answer;
- "Use the prompt() method to ask the user "What day is it?" and store the result in the answer variable." - We need to assign the value we get from the prompt to the variable we just created, answer. so
answer = prompt("What day is it?");
- "Use the document.write() method to write the variable answer to the page." - You don't need to use the alert function, but you do need to use
document.write(answer);
lance leach
2,402 PointsI tried this I just don't see what I am not getting. When I do what I think your asking I get I did not put the what day is it in the prompt function
var answer answer= prompt("what day is it?"); document.write(answer);
Yuval Blass
18,134 PointsThere is a little problem with this challenge; You need to do var = prompt("What day is it?");
with an uppercase W
. Hope this helps. ?
? Yuval ?
lance leach
2,402 Pointsyes thank you that resolved it. I was really pulling my hair out on this one. I appreciate everyones help
lance leach
2,402 Pointslance leach
2,402 PointsIm sorry im not following if I take and do the following I get a you did not put what day is it in the prompt function
var answer
var answer= prompt("what day is it"); alert(answer);
Alexandra Edwards
4,686 PointsAlexandra Edwards
4,686 PointsJust take out alert(answer) and you got it!
var answer = prompt("what day is it?");
Does it make sense now?
lance leach
2,402 Pointslance leach
2,402 Pointsno sorry I just dont see it var answer var answer = prompt("what day is it?");
I still get the same failure notice as before although the pop up work
Alexandra Edwards
4,686 PointsAlexandra Edwards
4,686 PointsOh weird. It appears the string is case sensitive for completing the challenge. That would only be the case for this challenge though. It normally wouldn't matter.
var answer = prompt("What day is it?");