console.table for lists of records
Try this in your browser's own console: the same array becomes a neat table with an (index) column.
The console is where your program talks back to you: console.log and its relatives print values, you can type and run JavaScript there directly, and every error shows up with its type, message and the line that caused it.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 5 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write code that stores a price of 250 and a discount of 50, then logs Price after discount: 200, and logs a warning Discount is more than 10% because it is.
This code throws. Say which error type and why, then fix it: const list = document.querySelector("#items"); list.append("tea"); on a page with <ul id="item"></ul>.
Explain it without notes
How do you read a console error message? Use an example.
What is the difference between a SyntaxError, a ReferenceError and a TypeError?
When would you use console.warn or console.error instead of console.log?
Why can logging an object in DevTools show different values when you expand it?
Preview
Console
Nothing logged yet.Expected console output
[ { name: 'Asha', score: 91 }, { name: 'Ravi', score: 78 }, { name: 'Meera', score: 85 } ]
Players: 3