Back to the lesson

Show an alert with an external script

importance: 5

Take the solution of the previous task Show an alert. Modify it by extracting the script content into an external file alert.js, residing in the same folder.

Open the page, ensure that the alert works.

The HTML code:

<!DOCTYPE html>


  <script src="alert.js"></script>



For the file alert.js in the same folder:

alert("I'm JavaScript!");