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 trialtheofanissiassios
6,498 PointsCan't get beyond the first part
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) {
search = prompt(// <-- this parenthese is highlighted red in workspace. "Search for a product in our store. Type "list to show all products, or "quit" to exit.");
if (search === "quit") {
break;
}
} // <-- this brace is also highlighted in red.
I tried it on Chrome and Safari. Adblock turned off.
1 Answer
Jennifer Nordell
Treehouse TeacherThe reason this is highlighted in red is because you need to use different quotation marks. You have the same quotation marks throughout the prompt which is causing confusion.
It should look like this:
search = prompt( 'Search for a product in our store. Type "list" to show all products, or "quit" to exit.');
Otherwise, it believes that the first quotation mark around list is the end of the string it's supposed to use. So it thinks "list to show all products, or" is part of a piece of code or a variable and now it doesn't know what to do.
Hope this helps!
theofanissiassios
6,498 Pointstheofanissiassios
6,498 PointsAh, of course! I completely overlooked that.
Thanks a lot, Jennifer!