Assign only if condition is true in ternary operator in JavaScript
Don’t use the ternary operator then, it requires a third argument. You would need to reassign max to max if you don’t want it to change (max = (max < b) ? b : max). An if-statement is much more clear: if (max < b) max = b; And if you need it to be … Read more