JavaScript JavaScript Basics Introducing JavaScript Link to an External Script

Quintin White
Quintin White
iOS Development with Swift Techdegree Student 901 Points

How do I properly call the alert function?

Call alert function?

index.html
<!DOCTYPE HTML>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
</head>
<body>
  <script src="shout.js"></script>
  alert("I DID IT!");
</body>
</html>
shout.js

Samuel Elbaz
Samuel Elbaz
6,596 Points

Hi you are calling it correctly, though just not in the right file. Since it is a JavaScript function it should be getting called from your .js file.

2 Answers

Nicolas Marcaud
PRO
Nicolas Marcaud
Pro Student 8,798 Points

Like this :

<script>
   alert("I DID IT!");
</script>

Or, in this case, put the alert in the shout.js file.

<!-- index.html file -->
<script src="shout.js"></script>
// shout.js file
alert("I DID IT!");

It needs to be called inside of your opening and closing script tags.