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 trialWalika Pham
1,802 Pointsdocument.write() wrong placement Challenge task 3 of 3
Obviously I'm missing something. Where do I place this function?
var answer;
prompt("What day is it?");
var answer = prompt("Tuesday");
document.write(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>
2 Answers
KRIS NIKOLAISEN
54,972 PointsYou code for task 3 is ok. It is the code for task 2 where you have an issue. For task 2 you are to prompt "What day is it?" and store the result in answer
. In your code you prompt "What day is it?" but don't store the result. Then you prompt "Tuesday" and store the result in a redeclared answer
variable. There is no need to use var again once the variable has been declared. You just need to store the result of the first prompt as follows:
var answer;
answer = prompt("What day is it?");
document.write(answer);
Walika Pham
1,802 PointsI figured out!
I wasn't adding to the var answer, but adding additional lines. (see below)
var answer = prompt("What day is it?"); document.write(answer);
Walika Pham
1,802 PointsWalika Pham
1,802 PointsThank you for your Answer! I have tried your suggestion and still getting the Bummer message: It looks like you placed the 'document.write()' function in the wrong place.