This is the html code.
<!doctype html>
<html lang="en">
<head>
<title>Advanced JavaScript Project. </title>
<link rel="stylesheet" href="style.css">
<script src="learning.js"></script>
</head>
<body id="theBody">
<h3>Matching Game</h3>
<p>Click on the extra smiling face on the left.</p>
<div id="leftSide">
<h3>Left Div</h3>
</div>
<div id="rightSide">
<h3>Right Div</h3>
</div>
</body>
</html>
This is the JavaScript Code.
var body = document.getElementsByTagName("body");
for (var i = 0; i < 10; i++) {
var div = document.createElement('div');
div.innerText = i;
body.appendChild(div);
}
I'm not understanding as to why this code is not working as expected. I want to add 10 divs to html.