Letter Length of an Array

Alright guys so I have an array. umm… example.

var state = new Array();
state[0] = “Alabama”;
state[1] = “ALASKA”;
state[2] = “Arizona”;
state[3] = “Arkansas”;
state[4] = “California”;

Im trying to find out the length of this array in letters. Im thinking something along the lines of “state.length” but that pulls up the number of arrays. I want the letter length. How would I go buy doing that? The assignment is to find the avg of the letter length. so in this case.

state.length/5 <—even though this is deff wrong. But get the point?

Any links or pointers would be very useful.

Join the array contents together, so that you can then take the length of that.

I did actually. Now i have:

state[i]

which is what created the loop. “i++” and so forth. But when i document.write state[i].length it gives me the length of each individual state rather than the sum.


function averageArrayLen(array) {
    return array.join('').length / array.length;
}