Jump to content

console log


tucker11

Recommended Posts

Is this the correct coding for console.log?

 

document.write('<h1>My Grocery List</h1>');
var groceries = getGroceries();
printGroceries(groceries);
function getGroceries() {
var debug = true;
var input = prompt ("Enable debugging (Y/N)", "");
if (input != "N" && input != "n") debug = true;
if (debug) console.log("beginning script");
document.write('<h1>My Grocery List</h1>');
var items = [];
do
{
var basket = prompt("Enter an item to add to the grocery list (enter ‘q’ to quit):");
if(basket != 'q' && basket != 'Q')
items.push(basket);
} while (basket != 'q' && basket != 'Q')
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 + '</ol>');
}
Link to comment
Share on other sites

What sort of answer are you looking for? I don't see any obvious errors in your use of console.log, although console.log is usually used to display variable values, and I think it would be more common to make debug a global. Also you are using document.write, which is usually avoided except in unique situations.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...