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 Introducing the Practice

Sun Min
Sun Min
2,941 Points

why my code is not running after i put h1 tag

how to use h1 tags in js file?

my code is not running after i put h1 tag

var message = Math \with the numbers ' + firstNum + ' and ' + secondNum; document.write(message);

how should i put h1 tag?

4 Answers

var message1 = '<h1>'+"Math with the numbers " + number1 + ' and ' + number2 +'</h1>'; i had a lot of trouble putting in the <h1> tag with the concatenations and variables but this is how I fixed it

2,649 Points

Neither of those 2 solutions worked for me. Any other advise??

Dylan Carter
Dylan Carter
1,046 Points

i did it like this:

var message = `<h1>Math with the numbers ${numberOne} and ${numberTwo}</h1>`

Here is how to include the h1 elements with document write message. Key is that the quotes enclose the html elements as well as the message itself. document.write("<h1> Your Message Here</h1>"_)