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

Srikanth Srinivasan
2,741 PointsWhy is my code printing it out multiple times?
Can someone please explain why code is printing out the message multiple times? It doesn't make sense to me.
1 Answer

Steven Parker
225,769 PointsThe "+=" operator adds on to a string, leaving what was there before. So each time through the loop, the current record is added to the end of everything that was written before, and then the whole thing is output again.
Moving the "let html = '';
" statement inside the loop will allow it to start fresh each time, and output each student record only once.
Srikanth Srinivasan
2,741 PointsSrikanth Srinivasan
2,741 PointsLegend! It totally helps to get a second pair of eyes, I completely missed that. Thanks once again, Steven!