So i have this simple script that populates a variable with an array. I then use a function with a for loop to iterate trough the array to get it's index values.
function printAllArrayValues(array) {
for (var i = 0; i < array.length; i++) {
var c;
c += array[i];
}
return c;
}
var colorArray = ["brown", "blue", "green"];
alert(printAllArrayValues(colorArray));
The function returns a string containing all the array values but the first value = undefined. See fiddle: http://jsfiddle.net/vcyum/
Why is that?