I have written this JavaScript code, but I feel like there might be some redundancy. Does anyone have suggestions on how to improve and optimize this code?
var boxHeights = [];
$('.box').each(function() {
boxHeights.push( $(this).outerHeight() );
});
var maxHeight = Math.max.apply(Math, boxHeights);
$('.box').each(function() {
$(this).css('height', maxHeight+'px');
});