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

How to place each sentence on a new line of text with Templates?

I heard Guil mention that templates can only code 1 to 2 lines of strings at a time without a backslash. I think I misunderstood but in the example of my code how would I make each sentence a new line of text? Thanks for any help!

// 2. Combine the input with other words to create a story. let MadLib= `<h2>What Happens When A Unicorn Poops??</h2><p>Unicorns aren't like other ${pluralnoun1}; they're ${adjective1}.

\They look like ${animalpluralnoun1}, with ${pluralnoun2} for feet and a ${adjective2} mane of hair.

\But unicorns are ${color} and have a ${adjective3} ${noun1} on their heads.

\Some ${pluralnoun3} don't believe unicorns are ${adjective4} but I believe in them.

\I would love to ${verb1} a unicorn faraway ${pluralnoun4}.

\One thing I have always ${verbpast} about is whether unicorns ${verb2} rainbows, or is their ${noun2} ${adjective5} like any other animals?<p>`;

1 Answer

Jess W
Jess W
9,490 Points

You could add <p> and </p> surrounding each line, would that do the trick? Like: <p>They look like ${animalpluralnoun1}, with ${pluralnoun2} for feet and a ${adjective2} mane of hair.</p>