JavaScript JavaScript Basics Storing and Tracking Information with Variables The Variable Challenge

brendon hanson
brendon hanson
490 Points

Why Isn't it working! Variable challenge

Here is my code var adjective = prompt('Type an adjective'); var answer1 = adjective; var noun = prompt('Type a Noun'); var answer2 = noun; var verb = prompt('Type a verb'); var answer3 = verb; document.write('Hi, I am an alien from the the great planet of merso! I am very' + ' answer1' + 'I hope this does not scare you. My family lives in a' + ' answer2' + 'It is usually crowded so I find myself' + ' answer3'); Instead of the program showing the answer that the user types it literally just says answer1 Please HELP!

1 Answer

P M
P M
2,451 Points

You have enclosed the variables in quotes. While concatenating the variables do not need quotes.

var adjective = prompt('Type an adjective'); var answer1 = adjective; var noun = prompt('Type a Noun'); var answer2 = noun; var verb = prompt('Type a verb'); var answer3 = verb;

document.write('Hi, I am an alien from the the great planet of merso! I am very ' + answer1 + ' I hope this does not scare you. My family lives in a ' + answer2 + ' It is usually crowded so I find myself ' + answer3);

brendon hanson
brendon hanson
490 Points

Thanks, for some reason I keep making that mistake