tucker11 Posted April 11, 2015 Share Posted April 11, 2015 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 More sharing options...
davej Posted April 11, 2015 Share Posted April 11, 2015 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 More sharing options...
tucker11 Posted April 11, 2015 Author Share Posted April 11, 2015 I did some research and noticed exactly what you are saying. I think I got it. Thanks for the heads up! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now