SketchBookkeeper
5/22/2018 - 3:28 PM

Find Tallest Element

Reduce an array of html elements to find the talles one.

// accumulator is element a's height if possible.
// current value is element b's height that is being compared to element a
// if b is not an element, it will be 0

function getTallestElement(elements) {
	return elements.reduce(function(a,b) {

		a = a.offsetHeight || a;
		b = b.offsetHeight || 0;

		return Math.max(a, b);
	}, 0);
}