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!


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

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

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
full_list.push(last + ", " + first + ": " + score1);
// 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 () {

var last_click = function () {

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


window.onload = function () {
$("add_score").onclick = add_click;
$("clear_scores").onclick = clear_click;
$("last_sort").onclick = last_click;

Sign In or Register to comment.