How do take this following javascript and put in external javascript.
<html>
<head>
<script language="javascript" type="text/javascript">
test();
function counter(array){
var negatives =0;
var zeroes =0;
var positives=0 ;
var i=0;
for(i=0;i<array.length;i++)
{
switch (true )
{
case (array[i] == 0) :
zeroes++;
break;
case (array[i] > 0) :
positives ++;
break;
case (array[i] < 0) :
negatives ++;
break;
}
}
return "Negatives = "+negatives+"\nZeroes = "+zeroes+"\nPositives = "+positives;
}
function test(){
var myIntArray = new Array(10);
var i=0;
for(i=0;i<10;i++){
var num = prompt("Please enter a number","Please enter a number");
myIntArray[i] = parseInt(num);
}
var output = counter(myIntArray);
alert (output);
}
</script>
</head>
<body onload="test()">
</body>
</html>
To put the JavaScript code in an external file, follow these steps:
1. Create a new file with a .js extension (e.g., script.js).
2. Open the script.js file in a text editor.
3. Copy and paste the JavaScript code from the <script> tags in your HTML file into the script.js file.
4. Save the script.js file.
5. In your HTML file, replace the JavaScript code inside the <script> tags with a link to the external JavaScript file.
You can do this by adding the following line in the <head> section:
```html
<script src="script.js"></script>
```
Here's how the updated code would look like:
```html
<html>
<head>
<script src="script.js"></script>
</head>
<body onload="test()">
</body>
</html>
```
Now the JavaScript code is in a separate file, script.js, and linked to the HTML file.