The max monoid in javascript