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

gregsmith5
gregsmith5
32,615 Points

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