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

Probably an easy fix but I'm a noob at js.

I am building a simple program that asks users to select questions using the prompt command and then I display their answers on the webpage using document.write.

var test = prompt("this is a test"); document.write( "<h1>this is the " + test + "</h1>");

// I want the text to be written and then I want the second prompt to pop up.

var test = prompt("this is a test"); document.write( "<h1>this is the " + test + "</h1>");

1 Answer

Steven Parker
Steven Parker
229,670 Points

You can only declare a variable once. If you want to reuse the "test" variable, just leave off the "var" keyword on the second line.