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 do I change the font-size of a string printed out by document.write in JavaScript?

var name = prompt('Name your character'); var adjective = prompt('Describe your character'); var verb = prompt('What is your character doing?'); var noun1 = prompt('What is he wielding?'); var noun2 = prompt('what is he wearing?');

var story = name + ' is ' + adjective + ' and loves ' + verb + ' with a ' + noun1 + ' in hand. His favorite ' + noun2 + ' says it all.';

document.write(story.fontSize(7));

When i run this the prompts run but the document.write command does not print anything.

however if i change the last line to this

document.write(story);

everything works fine and the story is printed back out.

Have i missed something about string methods or does it hae something to do with workspaces?

2 Answers

Steven Parker
Steven Parker
243,318 Points

No, you haven't missed anything. document.write is not something you will use for very long in the courses, and most likely not at all in actual practice. You'll soon learn how to create and interact with HTML elements, which can also by styled in a variety of ways including font size.

Just keep plugging!

Roger that haha thank you! :D