```
return nums.reduce(function(p, n) {
return [p[1], Math.max(p[0] + n, p[1])];
}, [0,0])[1];
```

variable p records previous 2 max values: p[1] is the previous one and p[0] is the one before previous one. p is initialized as [0,0]. variable n is the value at each position.