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 trialDavid Sheridan
8,579 PointsHow do I store the answer in the variable?
I'm not sure why this isn't working, can anyone see any error or is my logic off?
var answer = prompt("what day is it?");
<!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
Jennifer Nordell
Treehouse TeacherHi there! Challenges are picky... and I mean super picky. Capitalize the "W" in What. "What day is it?" will pass. "what day is it?" will fail.
yannisverbecque
17,145 PointsCould you make a
console.log(answer);
to see if you can see your answer in the browser's console ?
alastair cooper
30,617 PointsYour code works fine in my browser.
Make sure that your browser is not disabled from giving alerts. Make sure that scripts is in the same file as the html.
check the console and query 'answer'. It gives the answer I gave in the prompt when I tried it.
Cheers
Alastair
Benjamin Hedgepeth
5,672 PointsWhen you execute the prompt() command in the browser, the value you input into the text box stores it into the variable 'answer'.
When you write the command
document.write(answer);
for instance, it will print the stored value of 'answer' in the document.
David Sheridan
8,579 PointsDavid Sheridan
8,579 PointsHit the nail on the head there, thank you!
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherDavid Sheridan You're quite welcome!