I have a function which takes the average of all the elements in an array. However, I am getting an unexpected identifier error.
function calculateAverage(anyArray) {
var sum = 0;
for (int i = 0; i < anyArray.length; i++) {
sum += anyArray[i];
}
sum = sum / anyArray.length;
}
I have counted my braces and parentheses and the error seems to be happening only when the for loop is included, as when I removed it the error does not occur.