Previous Lecture Complete and continue  

  Console.log

What is console.log

Now that we know what a string is, let's make a string and have it appear in the console! To do this, we use console.log. Console.log will allow you to view any item you give it in the console. To tell JavaScript that you want to run console.log, you type console.log and then a pair of parentheses. Inside of the parentheses, you type the item you want to log to the console. For example, if we want to log the string of 'I like puppies' to the console, the you would use the code below:

console.log('I like puppies');

The semicolon after the console.log tells JavaScript to end the statement. A statement is a piece of code that tells the computer to do some task. Although your code will still function properly if you omit the semicolon, many programmers consider it poor code style to leave out the semicolon.