1d Array |
1D Array in JavaScript:
<html>
<head>
<title>1D array</title>
<script type="text/javascript">
function f()
{
var x=[];
for(var i=0;i<10;i++)
{
var n=prompt("Enter the element"+i);
x.push(n);
}
for(var i=0;i<10;i++)
{
document.getElementById("d1").innerHTML+=(x[i]+"<br>");
}
}
</script></head>
<style type="text/css">
#d1
{
position:absolute;
width:100px;
top:20px;
left:20px;
height:200px;
border:1px solid black;
background-color:red;
}
</style>
<body onload="f()">
<div id="d1">
</div>
</body>
</html>
Output:
Enter the element0 to element9
More Related Program:
0 Comments