Holen Sie sich die größte Nummer in Array JavaScript
const array1 = [1, 3, 2];
Math.max(...array1);
// expected output: 3
Jerky
const array1 = [1, 3, 2];
Math.max(...array1);
// expected output: 3
const result = (data) => {
let max = 0;
for (let i = 0; i < data.length; i++) {
if (data[i] > max) {
max = data[i];
}
}
console.log("===> :: max", max);
}
const inputData = [2, 3, 5, 4, 54, 69, 4, 44, 3, 6, 45, 6, 4, 6]
result(inputData);
var array = [3 , 6, 2, 56, 32, 5, 89, 32];
var largest= 0;
for (i=0; i<=largest;i++){
if (array[i]>largest) {
var largest=array[i];
}
}
console.log(largest);
const max = arr => Math.max(...arr);
const array = [10, 2, 33, 4, 5];
console.log(Math.max(...array)
)
array.reduce((max,x) => max < x ? x : max);