Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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);
}