I am trying to get the maximum value in an array but when I try to display it I get every value from that array.
for (var ii = 0; ii < items.length; ii++) {
var myArray = [items[ii].odoEnd];
var highestEnd = (Math.max.apply(Math,myArray));
$("#trips").append("<li>" + items[ii].TripDate + " : " + items[ii].AKTripContact + "<br/>" +
items[ii].Comments + "<br/>" +
"Odometer: " + items[ii].odoStart +
" to " + items[ii].odoEnd +
"@" + items[ii].Rate + "/km" + "<br/>" +
items[ii].business + " : " + items[ii].Distance + "km : $" + items[ii].Amount + "</li>");
alert(highestEnd);
} // for
Why is my alert box giving me an alert for every value and not just the maximum?
Thanks