Locked lesson.
About this lesson
Learn several ways to output data to the screen with JavaScript.
Exercise files
Download this lesson’s related exercise files.
Output.docx58.6 KB Output - Solution.docx
58.8 KB
Quick reference
Output
There are several ways to output with JavaScript.
When to use
Whenever you need to output something with JavaScript, use one of these methods.
Instructions
Here are the four main ways to output to the screen:
.innerHTML
document.write();
window.alert();
console.log();
Hints & tips
- Depending on what you're outputting, you'll use a different method
- .innerHTML changes existing elements
- document.write(); writes to a web page
- window.alert(); creates a pop up message
- console.log(); outputs to the console
Lesson notes are only available for subscribers.