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 The Variable Challenge

story finished...hope it's good?

//Introductions before the fun begins.
console.log = ("Begin program");
alert("Welcome visitor! I humbly greet you on this fine day and hope your ready to help me create a fanciful tale today! Click  'Ok' to continue our tale.");

//This is where the user interactions occur; Prompts the users with questions.
var nameNoun = prompt("What is your name?");
var hobbyVerb = prompt("What is your favorite hobby?");
var feelingAdjective = prompt("In one word, describe yourself?");
var genderChoice = prompt("Are you a man or woman?");
var timeofdayChoice = prompt("What time of day?");
var locationChoice = prompt("Pick the first city in the medieval era that comes to thought.");

//Piecing everything together in a paragraph.

var paraOne = "In a land of mystery and magic" + ", " + "there was a young " + genderChoice + ". ";<br>
var paraTwo = "On a beautiful " + timeofdayChoice + ", " + "in the city of " + locationChoice + ", " + "there lived this young " + genderChoice + " who was called " + nameNoun + ". ";<br>
var paraThree = "This particular " + genderChoice + " would go " + hobbyVerb + ". ";<br>
var paraFour = "However" + ", " + nameNoun + " was feeling rather " + feelingAdjective + ", " + "and so" + ", " + "he decided he ought to go west of the Greensboro Forest" + ". ";<br>
var paraFive = "Only to " + nameNoun + "'s " +"dismay" + ", " + "did he find the earth scorched" + ", " + "and the sky reigning down in a fury of fire" + ": " + "meteorites " + ". ";<br>
var paraSix = nameNoun + "'s " + "world was changed to the sight of what he saw before him" + ": " + "an army of demonic beast flooding out of a portal" + ", " + "ripping through the very fabric of the world" + ". ";<br>

//This now combines the story into one.

var completeStory = paraOne + "<br>" + paraTwo + "<br>" + paraThree + "<br>" + paraFour + "<br>" + paraFive + "<br>" + paraSix;

//This part finalizes the story.

document.write(completeStory);

//This indicates to the user, the questions have ended, and they will see the story soon.

alert("I hope you enjoyed it thus far, because the fun is just started. Click 'ok' and see the magic of what your words have created today. Enjoy!");

//Tells the user the it's has come to an end.

alert("I bid you farewell, for our time has come to part ways.");

console.log = ("End program");
Steven Parker
Steven Parker
231,271 Points

I'm confused - do you have a question?

huckleberry
huckleberry
14,636 Points

Steven Parker I believe he's simply posting it to see if others have anything to say about it... critique or approval.

Cheers,

Huck - :sunglasses:

1 Answer

huckleberry
huckleberry
14,636 Points

Hello, Luke!!

First off, good job and getting the basics under way and more importantly, putting it into action!!

A couple of things I'd like to point out... just a few simple errors.

First thing I noticed is that it wouldn't run at all because it was throwing an error ... unexpected token. Starting on line 16

//Everything in this "Piecing everything together in a paragraph." part has 
//a <br> tag at the end of the line AFTER the closing semicolon. That ... well, that
//shouldn't be there and I don't know why you did that lol.

var paraOne = "In a land of mystery and magic" + ", " + "there was a young " + genderChoice + ". ";<br>
var paraTwo = "On a beautiful " + timeofdayChoice + ", " + "in the city of " + locationChoice + ", " + "there lived this young " + genderChoice + " who was called " + nameNoun + ". ";<br>
var paraThree = "This particular " + genderChoice + " would go " + hobbyVerb + ". ";<br>
var paraFour = "However" + ", " + nameNoun + " was feeling rather " + feelingAdjective + ", " + "and so" + ", " + "he decided he ought to go west of the Greensboro Forest" + ". ";<br>
var paraFive = "Only to " + nameNoun + "'s " +"dismay" + ", " + "did he find the earth scorched" + ", " + "and the sky reigning down in a fury of fire" + ": " + "meteorites " + ". ";<br>
var paraSix = nameNoun + "'s " + "world was changed to the sight of what he saw before him" + ": " + "an army of demonic beast flooding out of a portal" + ", " + "ripping through the very fabric of the world" + ". ";<br>

Simple remove those unnecessary br tags and you're golden.

//This now combines the story into one.

var completeStory = paraOne + "<br>" + paraTwo + "<br>" + paraThree + "<br>" + paraFour + "<br>" + paraFive + "<br>" + paraSix;

//This part finalizes the story.

document.write(completeStory);

//This indicates to the user, the questions have ended, and they will see the story soon.

alert("I hope you enjoyed it thus far, because the fun is just started. Click 'ok' and see the magic of what your words have created today. Enjoy!");

This part isn't broken or anything, it's just that you put the document.write(completeStory); before the part where you tell them to click 'ok' and see the magic of their words.

The way you have it now, the words print to the page before the alert box shows up. You should switch those two.

The last thing... it's nothing to do with the code or anything but the way your story works with the reader's 'hobby' that you ask them for can be a bit weird. For example, one time I said guitar and another time I said fitness. So the story wound up saying "This particular man would go guitar." and then "This particular man would go fitness" lol... so, might want to try re-wording that. If someone likes building model trains and they just say "trains" then you're gonna get the same kind of weirdness. Tons of examples but you get the point. I'm sure there's a way you could word it in the prompt so they know they have to use the -ing form of the verb ;)

Anyway, good job overall and keep on coding!!

Cheers,

Huck - :sunglasses: