Array Math.max su una matrice





'Utilizzo di Math.max () su una matrice

'È possibile utilizzare Math.max.applyper trovare il numero piu' alto in un array:


'Esempio

'function myArrayMax(arr) {

' return Math.max.apply(null, arr);

'}


' Math.max.apply(null, [1, 2, 3])e' equivalente a Math.max(1, 2, 3).


https://www.w3schools.com/js/tryit.asp?filename=tryjs_array_sort_math_max

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Array Sort</h2>

<p>The highest number is <span id="demo"></span>.</p>

<script>
var points = [40, 100, 1, 5, 25, 10];
document.getElementById("demo").innerHTML = myArrayMax(points);

function myArrayMax(arr) {
return Math.max.apply(null, arr);
}
</script>

</body>
</html>











( arraymathmaxsuunamatrice.html )- by Paolo Puglisi - Modifica del 17/12/2023