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 Using For Loops with Arrays

Zeljko Porobija
Zeljko Porobija
11,491 Points

print(listHTML) prints the document

Strange, but if I keep line 20 of the code print(listHTML) my computer goes to print this (on a printer). I've changed that line to document.write(listHTML) and everything goes fine. Is that because we no longer have the helpers.js file available to link it with index.html?

2 Answers

Per Karlsson
Per Karlsson
12,683 Points

Hi Zeljko Porobija,

Line 20 calls the print function in playlist.js. Did you accidentaly remove it? :)

--

You can try this out in the browser console (ctrl+shift+i in chrome for windows).

Try typing in print(), this should open up a print window that wants to print out the page. Close it down.

Paste this into your browser console and press enter.

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

Now try typing in print("Hello") instead and see what happens.

This is essentially what you did:

Image

Does it make sense? :)

Zeljko Porobija
Zeljko Porobija
11,491 Points

Wow, I commented that out (for the reason that escapes my mind). Thanks!