My problem is that I currently am having troubling using parseInt and an array. The goal is to allow a user to enter a series of numbers and than pass those numbers to an array which would be able to run arithmetic off of them.
Am I using this properly?
<html>
<head>
<title> lab7 </title>
</head>
<body>
<script>
var nums = new Array();
var integer;
var sum;
var average;
var counter;
var index = 1;
var integer_count;
var integer_total = 0;
while (index <= 10)
{
nums[index] = prompt("Enter a number");
nums[index] = parseInt(nums[index]);
integer_total = integer_total + nums[index];
index++;
}
average = integer_total / 10;
index = 1;
while (index <= 10)
{
if (nums[index] < average)
{
integer_count++;
}
index++
}
alert(average + integer_count);
</script>
</body>
</html>


Sign In
Create Account

Back to top









