Please extract this bit into a standalone function since it is repeated twice (L213).

Example:

```js
latest: getMaxVersion(versions)
```