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 trialidriss Elouilani
Courses Plus Student 1,232 Pointscreate var answer; then usedti prompt() to ask "what day is ?" and store the answer variable
create var answer; used the prompt () method to ask user "what day is it "and store the result answer variable
var answer; var answer=("what day is it ?"); alert (answer); I wrote like this it doesn't through second Question
var answer;
var answer= prompt("what day is it ?");
alert(sunday);
<!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>
3 Answers
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsJust do it like this:
// just store the prompt inside the variable you created in task 1
var answer = prompt("What day is it?");
// and don't add the alert() because you was never asked to create it
Joseph Davidson
8,667 PointsThis is your solution:
var answer = prompt("What day is it?");
document.write(answer);
You do not have to declare the variable twice.
SP Prabhakar
11,429 Points- you cannot declare same variable name two times with "var" key.
- read question carefully, it would be "What" in place of "what". 3.your final answer would be var answer = prompt("What day is it?"); document.write(answer);
good luck!!!