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 JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Two-Dimensional Arrays

seth fiscus
seth fiscus
1,391 Points

why is: function print(message) { document.write(message) } in the code

I don't understand why this function is in there when it is never called? Please help me understand thanks

1 Answer

jacksonpranica
jacksonpranica
17,610 Points

Hey Seth,

The function is actually called in the video. If you look in the "printSongs" function, he calls the function "print(listHTML)" near the end. Basically all it does is print the list that he created to the website. Its use here is only for visual purposes. All he wants to do is print that list to the webpage so you have some visual feedback that the program you just created worked.

It's really just a simple print function for javascript, since javascript doesn't really have the visual feedback some other programming languages have in a console. Sure you can use chromes console, but its hard to write functions there and see their results.

Cheers!