Sum up my item in array

below is my script,to sum up the number in my array…but the output is all the numbers in array and not the sum up numbers…

CorrectMark =correctArray[0]+correctArray[1]+correctArray[2]+ correctArray[3]+ correctArray[4];

pls help…thankx…thousand of thankx

Sounds a bit confusing :h:

Looks to me like your numbers are actually strings. When strings are added together they form a new string: “2” + “3” = “23” (strings), where 2 + 3 = 5 (numbers). Make sure your numbers are numbers and not strings. Here’s a function you can use to sum up all the numbers in your array then:

Array.prototype.sum = function(){
var output = 0;
for(var q=0;q<this.length;q++){
if(!isNan(this[q])) output += this[q];
return output;
// Usage:
test = [2,5,3]