android - Javascript Save Max Value of Loop Variable -


i have variable updated every 2 seconds new value ( speed ) , want keep saved highest value . how can do? snipper

var velocità = spazio / t1;    // km/h          console.log('stai andando a: ' + velocità);          document.getelementbyid("velocità").innerhtml = velocità; 

var max = 0; ... ... if(velocità > max)     max = velocità; 

Comments