I am printing out values of a values-array in a div. I have the following code which is working very well:
...
...
document.getElementById("div").innerHTML = "Value: " + values[i];
<div id="div">The Value will be displayed here.</div>
However some of the values in my values-array are negative, but I would like to only show positive numbers of the array. So if a number is negative, it should say 0 instead.
I tried the following but its not working:
...
...
document.getElementById("div").innerHTML = "Value: " + if (values[i] < 0) {0} else {values[i]};
Any clues or hints? I am new to javascript, help is appreciated.