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!
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
how do we use an <h2> tag to write a var directly into the HTML file?
I was trying to put the shoutOut variable directly into the Index.html file using the document.write() method. if we put just the variable shoutOut into the code like document.write(shoutOut), the size of the text is really small. I wanted to use the <h2> tag to increase the font size, does anyone know how to do that? below is my code, but it prints out the word " shoutOut " instead of the value in the variable shoutOut. Any help would be useful.
var shout = prompt("Write something");
var shoutOut = shout.toUpperCase();
shoutOut += "!!!!";
Thank you again, appreciate your help.
Steven Parker225,712 Points
There are a number of ways to do this, but the simplest is probably concatenation (joining strings together) with the "+" operator:
document.write("<h2>" + shoutOut + "</h2>");
But be aware that while this will display on the page in the browser, it does not add anything to the
Thanks for the solution.