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!

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

My solution to the special problem (it works finally) -- any suggestions?

https://w.trhou.se/ua0qjqamjq

It works! I am unreasonably happy about this.... Let me know if there are any improvements I can make to make it more maintainable, clearer to outside parties, or more efficient!

Thanks!

1 Answer

Hi Alex,

Looks pretty good. A couple of things you could do:

  1. the outputDiv is being gotten from the document every time the print function is called. That could be done outside the function so it's only grabbed once, and all the print function does is write some new output to it.
  2. Some simple version of templating could help build the report string instead of the rather long concatenation that's there now. This may help if you want to quickly re-format the report. Sometimes lots of concatenation confuses me; have I missed a plus sign, or have I put a semicolon in the right place, etc? Could use something like Handlebars, or write something very lightweight.

Hope this helps,

Ajay