Javascript examples for Array:sort
Get the lowest value in an array:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> var points = [40, 100, 1, 5, 25, 10,2,3,4,3,2,3,4]; document.getElementById("demo").innerHTML = points; function myFunction() {//from w w w . ja va2s. c om points.sort(function(a, b){return a-b}); document.getElementById("demo").innerHTML = points[0]; } </script> </body> </html>