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
Daniel Eckert
Courses Plus Student 1,756 PointsJavaScript print function; how does it work?
function print { var outputDiv = document.getElementById('output'); outputDiv.innerHTML = message; }
He briefly explains this code but I can't get my head around it. Can anyone explain what this code is doing in detail? Or link me to somewhere, where said information already exists?
1 Answer
Steven Parker
243,318 PointsYou forgot to include a link to the course page, so I'm not sure what was said about this.
But essentially, the first statement just finds the element that has the ID of "output". Then the next statement takes what was given to the "print" function as an argument and displays it on the page as the contents of the "output" element.