I am trying to create an application to display a certain number of list items based on the number input (i.e 3 = 3 list items). So far I have only been able to create a function that displays one list item with the onClick function. No matter what code I use, I cannot find a way to create multiple list items from one button click. Here is my current code, HTML:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<section>
<header>Week 5 Assignment</header>
<section>
<label>Name: <input type="text" id="nameInput" value="Enter a Name"></label>
</section>
<section>
<label>Num of Times: <input type="number" id="numInput" value="Enter Number"></label>
<section>
<ol id="nameOutput"></ol>
<hr>
<button onclick="displayName();">Display Name!</button>
<button>Reset</button>
</section>
</section>
</section>
<script src="script.js"></script>
</body>
</html>
And my JS:
var name = document.getElementById("nameInput").value;
console.log(name);
var num = document.getElementById("numInput").value;
var list = document.getElementById("nameOutput");
var item = document.createElement("li");
item.innerText = name;
list.append(item);
}