<html>
<head>
<title>To create an array of 10 elements and display its contents</title>
</head>
<body>
<script type="text/javascript">
var a = new Array(10); // Initialize an array with 10 elements
// Asking for input only once
alert("Please enter 10 names.");
// Collecting names through prompt
for (let i = 0; i < [Link]; i++) {
let name = prompt("Enter value for element " + (i + 1) + ":");
// Check if the input is empty
if (name === null || [Link]() === "") {
a[i] = "No input provided"; // default message for empty input
} else {
a[i] = [Link](); // Store the entered value
}
}
// Displaying values with more structured output
[Link]("<h3><b>Given values are:</b></h3>");
[Link]("<ul>");
for (let i = 0; i < [Link]; i++) {
[Link]("<li>" + a[i] + "</li>");
}
[Link]("</ul>");
</script>
</body>
</html>