The point of this code is to get it to populate in and ordered list after the user enters the grocery list value. I need it to list as:
1. Milk
2. Deodarant
3. soda
4. chips
Also, if the user enters q or Q without entering items I need the page to read : "Sorry, your grocery list is empty. Any and all assistance will be appreciated!
document.write('<h1>My Grocery List</h1>');
var groceries = getGroceries();
printGroceries(groceries);
function getGroceries() {
var canExit = false;
var items = []
do {
items = prompt("Enter an item to add to the grocery list (enter ‘q’ to quit):");
} while (items != 'q' && items != 'Q')
canExit = true;
return items;
}
function printGroceries(groceryItems) {
var groceryitems = i;
var msg = '';
msg += '<ol>';
for(var i = 0; i < groceryItems.length; i++) {
msg += '<li>' + groceryItems + '</li>';
}
document.write('<p>Here's your grocery list:</p>' + msg + '</li>');
}