CSE 154 Examples

What is the Console.log function?

Description :

The console.log() function is used to log what we want on the browser console. You can think of this as being similar to "System.out.println()" in Java or "print" in Python. To view the statements you log, you can "Right Click" on your Browser and click on "Inspect". Then click on the Console tab and what you printed onto your log should be visible here! This is often a great strategy when debugging to know if our JS script is executing properly.

Syntax to log on the console (JS) : console.log("message_to_log");

Exercise :

Here are the steps to view your print statements on the console

  1. Right click on your browser (in this case Chrome) screenshot showing right click on browser
  2. Click on inspect screenshot showing clicking on inspect
  3. Click on the Console Tab on the Inspect screen that opens up screenshot showing console
  4. You should see the the things you logged on the Console screenshot showing user messages on the console