Last active
December 20, 2017 23:45
-
-
Save brandonvanha/a2827490f97e5c180ac67c8cb061e3db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Return min or max key's value | |
// calendar_date is just an example placeholder. | |
// result.recordet is array of JSON Object. | |
var minNum = Math.min.apply( Math, result.recordset.map( function ( o ) { return o.calendar_date; } ) ); | |
var maxNum = Math.max.apply( Math, result.recordset.map( function ( o ) { return o.calendar_date; } ) ); | |
// Return entire JSON Object. | |
// calendar_date is just an example placeholder. | |
// result.recordet is array of JSON Object. | |
const min = result.recordset.reduce( function findMin( prev, current ) { | |
return ( prev.calendar_date < current.calendar_date ) ? prev : current; | |
} ); // return object. | |
const max = result.recordset.reduce( function findMax( prev, current ) { | |
return ( prev.calendar_date > current.calendar_date ) ? prev : current; | |
} ); // return object. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment