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
Anthony Lucio
20,431 PointsThe Build an Object Challenge, Part 2 Solution - Tracking Data Using Objects - Stage 3
After entering my code, previewing the workspace, approx 3:11 in the video, my preview page's console gives a , Uncaught SyntaxError: Unexpected end of input, message (for the 1st line of code (var message = ' ';)).
I wonder if anyone has the same problem.
I've tried:
replacing the quotes with different quotes entering and removing spacing between the quotes entering and removing spaces before and after quotes
Here's my code:
var message = ' ';
var student;
function print(message) {
var outputDiv = document.getElementById('output');
outputDiv.innerHTML = message;
}
for (var i = 0; i < students.length; i += 1) {
student = students[i];
message += '<h2>Student: ' + student.name + '</h2>';
{
print(message);
PS: Your vids rock Dave!
1 Answer
Mohammed Khalil Ait Brahim
9,539 Pointsvar message = ' ';
var student;
function print(message) {
var outputDiv = document.getElementById('output');
outputDiv.innerHTML = message;
}
for (var i = 0; i < students.length; i += 1) {
student = students[i];
message += 'Student: ' + student.name + '';
{
print(message);
// Check The opening '{' before print(message) ;) it should be '}'
The problem is at the end of the loop you don't close the brace { you open a new one. Hope it helps!
Anthony Lucio
20,431 PointsAnthony Lucio
20,431 PointsThank you Mohammed!