This is my HTML file:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>First javascript</title>
<link rel="stylesheet" href="css.css">
<script src="randomNumber.js"></script>
<script type="text/javascript">
getRandomNumber();
</script>
</head>
<body>
<p id="hello">Hello</p>
</body>
</html>
And this is my Javascript file.
window.onload = function getRandomNumber(){
var randomNum = Math.floor((Math.random() * 10) + 1);
console.log(randomNum);
document.getElementById("hello").innerHTML += randomNum;
}
I cant understand why the code is not working. I am new to programming so if you could give a quick then that would be great.
It's working.