JavaScript JavaScript Basics (Retired) Storing and Tracking Information with Variables The Variable Challenge

Reza Zandi
Reza Zandi
Full Stack JavaScript Techdegree Student 1,599 Points

Getting the printed story to be bigger

document.write("There once was a " + adjective + noun + " whom lived life soley to " + verb + ".");

Can I add something like an <h3> tag in between the parenthesis to make this bigger? How does one manipulate the size of the text that's being printed that way. I know this is beyond the scope for this video, but just wondering . Also, I tried to save the documents.write to a variable, just as 'var story = document.write("There once was a " + adjective + noun + " whom lived life soley to " + verb + ".");'

but that threw off an error. I was going to try to manipulate 'story'.

2 Answers

KRIS NIKOLAISEN
KRIS NIKOLAISEN
54,374 Points

You could use the fontsize method

var story = "There once was a " + adjective + noun + " whom lived life soley to " + verb + "."
document.write("<p>" + story.fontsize(7) + "</p>");

I tested it and it worked in Chrome but note from the link:

The fontsize() method is not standard, and may not work as expected in all browsers. The <font> tag is not supported in HTML5. Use CSS instead.

SO with inline CSS

document.write("<p style='font-size:40px;'>" + story + "</p>");

There is also a css file included in the workspace, so you could just add <p> tags in the document.write line and then style the p element in the css file. In fact when I tried this the p elements were already styled to be a larger font size than just using document.write with no tags at all.