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

JavaScript JavaScript Loops, Arrays and Objects Tracking Multiple Items with Arrays Useful Array Methods

I don't know may be there is any bug

I type exactly the same code as teacher but the problem is, when I search something on the search box, If I type milk then nothing will print to the screen but when I type quit then the program quit and then milk print to the screen So if I want to know that is there any milk in the store if not then I will buy bread but I can not do that until I quit the program by type Quit, Please Help Me Out .

Hey Sudhir, can you share your code here?

her is my code => https://w.trhou.se/lkv2z82q1t

2 Answers

Which browser are you using? I tried your code using Safari and had the same problem you're describing, but when I tried it in Chrome, everything worked just fine.

Yes, document.write() is known for issues on Safari and IE. I have tested this on Mozilla and it seems to be working fine. You can also try replacing document.write() with alert():

function print(message) {
  alert(message);
}