Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
614 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var baseExtremum = require('./_baseExtremum'),
|
---|
| 2 | baseGt = require('./_baseGt'),
|
---|
| 3 | identity = require('./identity');
|
---|
| 4 |
|
---|
| 5 | /**
|
---|
| 6 | * Computes the maximum value of `array`. If `array` is empty or falsey,
|
---|
| 7 | * `undefined` is returned.
|
---|
| 8 | *
|
---|
| 9 | * @static
|
---|
| 10 | * @since 0.1.0
|
---|
| 11 | * @memberOf _
|
---|
| 12 | * @category Math
|
---|
| 13 | * @param {Array} array The array to iterate over.
|
---|
| 14 | * @returns {*} Returns the maximum value.
|
---|
| 15 | * @example
|
---|
| 16 | *
|
---|
| 17 | * _.max([4, 2, 8, 6]);
|
---|
| 18 | * // => 8
|
---|
| 19 | *
|
---|
| 20 | * _.max([]);
|
---|
| 21 | * // => undefined
|
---|
| 22 | */
|
---|
| 23 | function max(array) {
|
---|
| 24 | return (array && array.length)
|
---|
| 25 | ? baseExtremum(array, identity, baseGt)
|
---|
| 26 | : undefined;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | module.exports = max;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.