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 trialBhushan Gunaghe
2,451 Pointserror
var message = ''; var student; var x;
function print(message) { var outputDiv = document.getElementById('output'); outputDiv.innerHTML = message; }
function getrecord(student){ var record = '<h2>Student: ' + student.name + '</h2>'; record += '<p>Track: ' + student.track + '</p>'; record += '<p>Points: ' + student.points + '</p>'; record += '<p>Achievements: ' + student.achievements + '</p>'; return record;
} while(true) { var x = prompt('Type the name of whose information you want'); if (x.toLowerCase() === quit) { break; } for (var i = 0; i < students.length; i += 1) { student = students[i]; if(student.name === x) { message = getrecord(student); print(message); } } }
Can you tell me where exactly is the error coming??
1 Answer
Antti Lylander
9,686 PointsPlease take a snapshot of your workspace. If this is all your code, var student
does not have any of those properties called in your code. You are also declaring var x
two times (at the beginning and inside while loop).
In your first if statement (x.toLowerCase() === quit)
, quit
should be quoted as it is not a variable but a string.
Also students
is not defined.