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 and Writing It to the Page

idriss Elouilani
idriss Elouilani
Courses Plus Student 1,232 Points

create 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 ?");
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
<script src="scripts.js"></script>

3 Answers

Henrik Christensen
Henrik Christensen
Python Web Development Techdegree Student 38,322 Points

Just 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

This is your solution:

var answer = prompt("What day is it?");

You do not have to declare the variable twice.

SP Prabhakar
SP Prabhakar
11,429 Points
  1. you cannot declare same variable name two times with "var" key.
  2. 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!!!