JSFiddle - React, Tailwind, and code Playground

by Jeff

JavaScript

function blue() {
    alert("You start walking on the blue road");
    alert("You spot a grocery store at the side of the road.");
    alert("You decide to walk inside, and buy yourself some food.")
    alert("You open the door to the store, you hear a loud bell as you opened the door.")
    alert("You notice the cashier turning her head towards you.")
    alert("You take a bag, and nods politely, then walks in to the store.")
    alert("Heres a list of all the things available in the store.")
    var inStock = ['apples', 'eggs', 'milk', 'cookies', 'cheese', 'bread', 'ham', 'carrot',
        'broccoli', 'pizza', 'crackers', 'onion', 'banana', 'frozen dinner', 'cereals'
    ];
    var search = prompt(inStock + " " + "Choose wich things you wanna buy, type 'done' when you are done." + " type one thing at the time.");
    var bag = [];
    bag.push(search); 
    while (inStock.indexOf(search) > -1) {
        alert("You grabbed a " + search + " and put it in the bag")
        search = prompt(inStock + " " + "Choose wich things you wanna buy, type 'done' when you are done." + " type one thing at the time.")
        if (search === "done") {
            grocery();

        }else{
         bag.push(search);   
        }

    }

    function grocery() {
        alert("You decided that its enough");
        alert("In your bag you have " + bag.join(", "));
    }   

}

blue();