Here is my javascript program and it supposed to output the alert statement at the bottom of the code but is not apppearing. Why is it?
//function mean
function mean(values, callback) {
var total = 0;
for (var i = 0, max = values.length; i < max; i++) {
if (typeof callback === "function") {
total += callback(value[i]);
} else {
total += values[i];
}
}
}
var result = mean([2, 5, 7, 11, 4], function (x) {
return 2 * x;
});
alert("The result mean is " + result + ".");
total += callback(value[i]);-- should bevaluesnotvalue. Keep your browser console open so that you can see errors reported.