JavaScript one line solution functional programming
\nvar largestAltitude = (gain, prev = 0) => gain.reduce((max, curr) => Math.max(max, prev += curr), 0);\n
```\nvar largestAltitude = (gain, prev = 0) => gain.reduce((max, curr) => Math.max(max, prev += curr), 0);\n```
['JavaScript']