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 Solution

Harrison Greeves
Harrison Greeves
2,920 Points

I've done mine slightly differently but...

my code won't include a space between the adjective, verb, and noun?

<h2>There once was a [adjective] slug who wanted to climb up a tree to [eat] the [noun].</h2>" 

var adjective = prompt("Give me an adjective");
var part1 = "<h2>There once was a " + adjective;
var verb = prompt("Give me a verb");
var part2 = "slug who wanted to climb up a tree to" + verb;
var noun = prompt("Give me a noun");
var part3 = "the " + noun ;
alert("You're finished!");
var sentence = part1 + part2 + part3;
document.write(sentence);
Lee Owen
Lee Owen
7,907 Points

Hey Harrison,

Overall your solution looks great, its just a few minor issues that are throwing your code off.

First, in var part1, you have an opening tag for <h2> but no closing tag anywhere else in your solution. And just so you know, the <h2></h2> tag is not needed, just makes the text larger than normal.

Next, for the spacing issues, you have two choices. You can put in spaces before and or after your part variables, so that when you add on the next part, it will come built in with spaces. So for example in part2, put a space before slug, so that when you put part1 and part2 together, it will have a space.

Additionally, you can put spaces in your actual sentence variable, so sentence = part1 + " " + part2 + " " + part3.

2 Answers

Steve Mustanski
Steve Mustanski
15,093 Points

I am new to the site, but know some javascript/html.

Try putting a space before "slug" and after "to" in part2. Also, before "the" in part3.

var part2 = " slug who wanted to climb up a tree to " + verb;

I also haven't done this exercise, but I would suspect you would need to put a "+ </h2>" after noun in part3 so the line would look like

var part3 = " the " + noun + "</h2>";

Hope that answers your question.

Chinelo Okafor
Chinelo Okafor
647 Points

Nice one Steve. I share same thoughts.