JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables The Variable Challenge

Alex Lang
Alex Lang
1,110 Points

What did I do wrong? nothing is working?

var noun = prompt ('Please Type a Noun'); var answer1 = noun;

var verb = prompt ('Please Type a Verb'); var answer2 = verb;

var adjective = prompt ('Please type an Adjective'); var answer3 = adjective;

document.write('<h1>Hello, my name is Gary and I am a "+ answer1 +".<h1><h2>I often like to "+ answer2 +" for my morning exercise.<h2><h3>I am very "+ answer3 +", I hope this does not scare you.<h3>');

alert("Typing up story now!")

var story = answer1 + answer2 + answer3

document.write(story)

1 Answer

Steven Parker
Steven Parker
202,104 Points

It's probably "working" but not doing what you intended. Since in the first "document.write", the entire argument is enclosed with apostrophes ("single quotes"), then everything between them will be shown as-is, quotes and all. If you change the apostrophes on the outside to quotes that match the ones used in the rest, then the quotes and plus signs will not be shown and the variable values will appear instead of the variable names.

Alex Lang
Alex Lang
1,110 Points

I just found out that the "s" in "story.js" was capitalized on accident and messed up everything but now I have it fixed and it works! Thanks for trying to help me! :)

Steven Parker
Steven Parker
202,104 Points

Sometimes the problem can be in a place you don't expect. That's why if possible, always make a "snapshot" of your workspace and post the link to it.