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 Working with Strings Variables and Strings Challenge Solution

Danny Chang
Danny Chang
1,006 Points

Does it matter where I use the <p> tags?

My code:

// 1. Declare variables and capture input.
let verb = prompt("Name a verb.");
let adjective = prompt ("Name an adjective.");
let noun = prompt ("Name a noun.");

// 2. Combine the input with other words to create a story.
let story = `There once was a man who ${verb} for his ${adjective} ${noun}. The end.`;

// 3. Display the story as a <p> inside the <main> element.
document.querySelector("main").innerHTML = `<p>${story}</p>`;

I see that they put they used the <p> tags between the backticks in the second section.

I used it at the third section.

// 3. Display the story as a <p> inside the <main> element. document.querySelector("main").innerHTML = <p>${story}</p>;

Does it make a difference if I put it in the second or third part?

// 2. Combine the input with other words to create a story. let story = There once was a man who ${verb} for his ${adjective} ${noun}. The end.;

1 Answer

Steven Parker
Steven Parker
231,236 Points

The method shown in the video will produce the exact same end result, so for functionality which step the tags appear in doesn't matter.

In the code above, there should only be one each of part 2 and part 3; but otherwise, your approach seems to fit the instructions even more accurately than the video example. Good job!   :+1: