Issue Averaging Array - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Issue Averaging Array

Posts: 5Member
Hello all, I have a project I am working on, and I am so close to finishing. Unfortunately this last bit has snagged me. Using this code, it appears that instead of actually adding each numerical value together, it is adding each new value to the end of the string. thus 5+8=58 ect... I would appreciate any pointers.

Below is the javascript code, and I have attached all of the files used in the application

[code]
var score_list = [];
var full_list = [];

var \$ = function (id) {
return document.getElementById(id);
}

var add_click = function () {
var last = \$("last_name").value
var first = \$("first_name").value
var score1 = \$("score_input").value
score_list.push(score1);
full_list.push(last + ", " + first + ": " + score1);
update_full_list();
// Beginning of issue
var Sum = 0
var Average
// Find the lowest & highest
for (var i = 0; i < score_list.length; i++) {
Sum=Sum + score_list[i] //as i understand it, this should be adding all of the array up in one value instead of just stringing them together
Average = Sum/score_list.length
}
alert(Sum); // I used this to show me what value it was getting for sum, and it displays the strung together numbers instead of the sum I want
//end test code

}

var clear_click = function () {
full_list.splice(0,999999);
update_full_list();
}

var last_click = function () {
full_list.sort();
update_full_list();
}

var update_full_list = function () {
var list = "";
for ( var i in full_list ) {
list += (parseInt(i)+1) + ": " + full_list[i] + "
";
}
\$("score_list").value = list;

}