Find The Min/Max Values In An Array - jQuery min-max.js

Find The Min/Max Values In An Array - jQuery min-max.js
File Size: 1.32 KB
Views Total: 41
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Calculate the Max/Min value from a JS array using Math.max() and Math.min() functions and output the results in any element using jQuery.

See Also:

How to use it:

1. Load the latest jQuery library (slim build) in the document.

<script src="/path/to/cdn/jquery.slim.min.js"></script>

2. Get the maximum and minimum values from an array you provide.

let array = [50, 60, 20, 80, 1, 30];
var minValue = Math.max(...array);
var maxValue = Math.min(...array);

3. Show the maximum and minimum values on the page.

$('.min').append(maxValue);
$('.max').append(minValue);
Minimum Value Is: <span class="min"></span>
Maximum Value Is: <span class="max"></span>

This awesome jQuery plugin is developed by bhavanas-jpg. For more Advanced Usages, please check the demo page or visit the official website.