I’m trying to learn html5 and js, so I’m following a tutorial and when i try to call the javascript file it obviously isn’t called… why is this? I followed the tutorial exactly but can’t achieve the same results. The html and js file are in the same folder so what gives?
Here is html
<!doctype html>
<html lang="en">
<head>
<title>HTML5 Example</title>
<script type="text/javascript" src="person2.js"></script>
<script type="text/javascript">
function init() {
var lee = new Person("cool_guy", "3445 market street")
lee.sayHello();
console.log(lee);
}
</script>
</head>
<body onload="init()">
</body>
</html>
here is javascript
(function(window) {
function Person(name, address) {
this.name = name;
this.address = address;
}
Person.prototype.sayHello = function() {
console.log(this.name + " says hello");
};
Person.SPECIES = "human";
}(window));