题目:
<html>
<body>
<script type="text/javascript">
var arrNumber = new Array()
var number;
while (number!=-1){
number=prompt("Enter a number (-1) to stop:");
if (number!=-1){
arrNumber.push(number);}
};
var allInput="";
for (i=0;i<arrNumber.length;i++)
{
allInput=allInput+arrNumber[i]+" ";
}
document.write(allInput+ "<br />")
</script>
</body>
</html>
还有一种写法:
<html>
<body>
<script type="text/javascript">
var arrNumber = new Array()
var number;
while (number!=-1){
number=prompt("Enter a number (-1) to stop:");
arrNumber.push(number);
};
arrNumber.pop();
var allInput="";
for (i=0;i<arrNumber.length;i++)
{
allInput=allInput+arrNumber[i]+" ";
}
document.write(allInput+ "<br />")
</script>
</body>
</html>