I am working on an assignment which requires that I link an external JS file into an HTML file. Here's the JS (file name 'whileLoop.js'):
function evenCount () {
var loopCount = 2;
while (loopCount <= 101) {
document.write(loopCount + " is an even number. <br /">);
loopCount = (loopCount + 2);
}
}
And here's the HTML:
<!DOCTYPE html>
<head>
<title>JS Assignment</title>
<head>
<body>
<script type="text/javascript" src="/whileLoop.js"></script>
</body>
</html>
If I copy the raw JS code (without the function call) into the HTML file inside the tags, then the HTML outputs correctly. When I attempt to link to the JS file inside the HTML file, the HTML outputs a blank page.
The expected output is a page that lists every even number between 2 and 101.