JSFiddle - React, Tailwind, and code Playground

JavaScript

var stock = ['apples', 'eggs', 'milk', 'cookies', 'cheese', 'bread'];
var exitLoop = false;

function isInStock(check){
    var checked = stock.indexOf(check);
    while (exitLoop === false) {
        if (checked >= 0) {
            alert(check + " is in stock.");
            exitLoop = true;
        } else if (check.toLowerCase(", ") === 'list') {
            alert(stock.join(', '));
            exitLoop = true;
        } else if(check === "" && check === null) {
            alert(check + ' is not in stock.');
            exitLoop = true;
        } else {
            alert("Something went wrong.");
            break;
        }
    }
}

isInStock(prompt("Search for a product in our store. Type \'list\' to show all of the produce and \'quit\' to exit."));