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 trialguarlonmirka
10,192 PointsHTML +=
I can see dave adding the follwing:
html = "You got " + correctAnswers + " question(s) right.";
html += "<h2>You got these question correct: </h2>";
html += buildlist(correct);
html += "<h2>You got these question wrong: </h2>";
html += buildlist(wrong);
Is this the only way to write it? Thanks
1 Answer
Daniel Botta
17,956 PointsYou could write it like this...
html = "You got " + correctAnswers + " question(s) right." +
"<h2>You got these question correct: </h2>" +
buildlist(correct) +
"<h2>You got these question wrong: </h2>" +
buildlist(wrong);
But as Ryan said, it just looks more messy and is harder to read.
Ryan Foote
14,435 PointsRyan Foote
14,435 PointsMultiline strings in JS can be kind of messy, using the method the instructor suggests makes it a bit easier to read.
http://davidwalsh.name/multiline-javascript-strings