Nickel Palladium Manganese
Join us to discuss the challenges, solutions and best practices for in-house JavaScript code sharing. Tuesday, 12/17 at 10am PT/1pm ET.Sign up here »

recursive-max

0.1.0 • Public • Published

recursive-max

Returns the largest number from a multidimensional array or object.

npm install recursive-max

Build Status

About

An easy to use solution for finding the largest number from a multidimensional array or object.

Arrays and objects are traversed recursively, number values are compared, the rest are skipped.

Returns false on failure.

Syntax

recursiveMax(objOrArray, max)

objOrArray

Object or array to fetch the maximum number from.

max

Optional. Use it to specify a temporary maximum value.

Usage

Call recursiveMax() by passing the array or object you wish to find the largest number from. If you specify max, it will be the maximum possible result.

var input = [0, 11, [4, 15]];
var max = recursiveMax(input);
 
console.log(max); // 15

License

MIT

Install

npm i recursive-max

DownloadsWeekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • avatar