Would someone mind converting this line of ternary code to if/then statements. I understand ternary, but am not able to get syntax errors to go away when I convert to if/then. This is the only line of my homework I had to borrow and I’d like to make it into if/then so that I can comment on it and understand it better myself.
Original:
return n == null || isNaN(n) ? 0 : n;
My attempt:
return n == null || if(isNaN(n)){return 0;}else{return n;}
You have to move the
returnand have a separate one for the if and the else: