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

I don't get this JavaScript Function?

What is the point of this function? Im confused on what It exactly does.

function print(message) {
  document.write(message);
}

It just change the content of the document and writes the message passed as parameter to your function.

1 Answer

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Brandon,

That function will take the value passed in as "message" and print it to the document.

For example, if I passed "Hello, Brandon" to the function like this.

print('Hello, Brandon');

document.write(message) will add 'Hello, Brandon' to the document associated with the JavaScript.

I hope this helps.

Oh okay I get it now. Thanks!