js: recursive max and min, would like to find a way to reuse the code and just alter the operator in some type of partial application structure