I was viewing the intermediate code solution on freeCodeCamp Algorithm Challenge Guide: Return largest Numbers in Arrays and noticed the unusual notation style used on the innermost return statement (current > prev) ? current : prev;
. Can anyone explain it to me? Thank you in advance.
2 Likes
It’s a ternary operator. It is a shorthand of if else.
If the condition is true, it returns current else prev.
1 Like