To create an array of 10 elements and display its contents using javascript

<html>
<head>
<title>to create an array of 10 elements and display its contents</title>
</head>
<body>
<script type="text/javascript">
var array_1 = new Array(10);
var i;
for (i = 0; i < array_1.length; i++) {
    array_1[i] = parseInt(window.prompt("Enter the value"));
}
document.write("Given  values are" + "<br />");
for (i = 0; i < array_1.length; i++) {
    document.write(array_1[i] + "<br />");
}
</script>
</body>
</html>

No comments:

Post a Comment