0

I want to collect three numbers and then identify the highest number. The numbers are the outer heights of div-elements. I tried to store the outer heights in an array but unfortunately I don't know how to do so. This is how I started:

$ var heights = [];

$('.elements').each(function(i){
   $(this).outerHeight(trainingshoehen[i]);
}); 

But it does not work. How can I write these numbers into an array and in the second step how can I compare these numbers best?

Would be nice to get any tips! Thnak you.

iMax
  • 547
  • 1
  • 8
  • 18
  • [var max_of_array = Math.max.apply(Math, array);](http://stackoverflow.com/a/6102340/958375) Will work to find the max of a small data set. – Joshua W Nov 11 '14 at 16:24

1 Answers1

1

I think this is what you're looking for. It will get the outerHeights of the elements and push them to the heights array.

var heights = [];

$('.elements').each(function(i){
    heights.push($(this).outerHeight())
}); 

var maxHeight = Math.max.apply(Math, heights);
KidBilly
  • 3,408
  • 1
  • 26
  • 40