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 trialFilip Diarra
6,647 PointsJavascript Issue..Please help.
Please let me know what is wrong with this code. I keep getting unexpected end of input error, but I think I'm following the teacher pretty much to the tee.
var inStock = [ 'apples', 'eggs', 'milk', 'cookies', 'cheese', 'bread', 'lettuce', 'carrot', 'broccoli', 'pizza', 'potato', 'crackers', 'onion', 'tofu', 'frozen dinner', 'cucumber'];
var search;
function print(message) { document.write( '<p>' + message + '</p>'); }
while ( true ) { var search = prompt("Search for a product in our store. Type 'list' to show all products. Type 'quit' to exit."); if (search === 'quit') { break; }
Thanks!
2 Answers
Benjamin Barslev Nielsen
18,958 PointsThis is your while loop:
while ( true ) {
var search = prompt("Search for a product in our store. Type 'list' to show all products. Type 'quit' to exit.");
if (search === 'quit') {
break;
}
You have forgotten a } to close the body of your loop.
Filip Diarra
6,647 PointsAlso, this doesn't work whether I use "var" in the body of the function or not.
Ashish Mehra
Courses Plus Student 3,575 PointsFilip Diarra , You forget to close while condition on line 31.