#5 Max Array Value

Emad Ibrahim
Jun 3, 2016 · 1 min read

If you have an array:

someArray: Ember.A([3,2,4,1])

You can get the maximum value with a computed property

maxNumber: Ember.computed.max('someArray')

The maxNumber property will always have the maximum value in the array and will auto re-compute and update any bindings automatically.
Here is some sample code:


You can get the minimum with


See more at http://emberjs.com/api/classes/Ember.computed.html

Originally published at Ember Daily Tips.

    Emad Ibrahim

    Written by

    Husband, Father of Twins, Published Author, Entrepreneur, Passionate Technologist, Programmer and Productivity Nut. more at https://about.me/eibrahim