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 trialjohn cook
Courses Plus Student 358 PointsThe Student Record Search Challenge Solution code doesn't work in bracket text editor.Please help
i copied the exact solution provided by the tutor into bracket text editor but the code doesn't work. below are the error messages
ESLint (5)
ERROR: 'document' is not defined. [no-undef] var outputDiv = document.getElementById('output');
ERROR: Unexpected constant condition. [no-constant-condition] while (true) {
ERROR: 'prompt' is not defined. [no-undef] search = prompt('Enter student name or Enter "QUIT" to quit');
ERROR: 'students' is not defined. [no-undef] for (var i = 0; i < students.length; i += 1) {
ERROR: 'students' is not defined. [no-undef] student = students[i];
1 Answer
Steven Parker
231,275 PointsI have not used brackets myself, but the message "'document' is not defined" makes me think the code is being executed directly in the editor. This is the same error I would expect if I tried to run using Node.js, since "document" is a property of the "Window" object that is provided by the browser, but it does not exist in pure JavaScript.
Does brackets have a "browser mode", "preview", or some other simulation mechanism that you need to turn on?
john cook
Courses Plus Student 358 Pointsjohn cook
Courses Plus Student 358 Pointsit has a browser live preview. When it turned on the prompt box shows but when the name is entered it doesn't show in the browser. it only responds to 'QUIT' to end the program
Steven Parker
231,275 PointsSteven Parker
231,275 PointsIt's normal for modern browsers to not render the page until the script finishes. If you do a search and then "quit", don't you see the results of the search then?