I have the following array. I am trying to get the element having maximum id by grouping by the entryId in `node.js`. 

```
[
    {
        "entryId": "7wpNAXhYI",
        "id": 5
    },
    {
        "entryId": "7wpNAXhYI",
        "id": 6
    },
    {
        "entryId": "5PGB23RI",
        "id": 7
    },
    {
        "entryId": "5PGB23RI",
        "id": 8
    }
]

```

The typical sql syntax would like as follows:  

`select entryId, max(id) from table group by entryId`

I have written the following code which would get just the max without grouping by. Any help how to modify the following code or any simple approach available.

```
function getMax(array) {
  var max = {};
  for (var i = 0; i < array.length; i++) {
    if (parseInt(array[i].id) > (parseInt(max.id) || 0))
      max = array[i];
  }
  return max;
}

```