Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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