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
Victor Kossoski
2,317 Points404 Not Found? Getting 404 after final alert() and before document.writ()
I am using the workspace for the madlibs task, getting 404 error before document.write() and after all the prompt() and alert(), see my code below:
var personTwo; var location; var theEvent; var reasonWhy; var theEnd;
var firstName = prompt("What is your name?"); personTwo = prompt("Who is with you in your little adventure?"); location = prompt("Where did you crazy cats go together?"); theEvent = prompt("Then all of a sudden something incredible happened! What was that?"); reasonWhy = prompt("Why did that incredible thing happened?"); theEnd = prompt("How did your adventure end?"); alert("Thank's For Playing!!");
var answer = (firstName +" and " + personTwo +" went to " + location + " and then suddenly " + theEvent + "!" + " because " + reasonWhy + " and in the end things ended " + theEnd);
document.write(answer);
Thanks for the help :)
1 Answer
Steven Parker
243,656 Points
Don't use "location" as a variable name.
The variable name "location" is reserved for the URL of the current page. Changing it causes the browser to attempt to load a new page using the value being assigned.