Is it possible to do something like this in JavaScript?
max = (max < b) ? b;
In other words, assign value only if the condition is true.
You can just set max to itself if the condition is false.
max
max = (max < b) ? b : max;
Or you can try using the && operator:
&&
(max < b) && (max = b);
Or to keep your code simple, just use an if.
if
if(max < v) max = b;