+ 1

How to define the max value in array[0].x;

function s(x) { this.x = x; } var array = [ [ new s(100), new s(0), new s(1020) ], [new s(100)], [new s(100)] ]; //the max value in array[0].x is 1020 but how to do it, please.

13th Jul 2019, 2:37 PM
MILSON
MILSON - avatar
2 Réponses
+ 3
var max = Math.max(...array.flat().map(a=>a.x)); https://code.sololearn.com/WrCI9kkw5weV/?ref=app
13th Jul 2019, 3:05 PM
Calviղ
Calviղ - avatar
+ 2
Thank you.
13th Jul 2019, 3:06 PM
MILSON
MILSON - avatar