3.1
A first script
In your project directory, create a new file and call it
script.js
.The script file has to be included in the HTML structure with the
script
tag. Thescript
tag should be added at the very end of thebody
tag (after every other tag insidebody
, just before</body>
).Add the code to
script.js
.
When you open the web page you should see a dialog display the text.
???
The first line creates a variable called text
and assigns the text wwwow!
to it.
The second line calls a function called alert
and passes the variable as an argument.
index.html
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Titel</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
script.js
let text = 'wwwow!'
alert(text)