Having a JSON in this format: how can I combine the objects by name, country, and countryID in Javascript to get the following JSON output? Answer Using Array.prototype.reduce, you can group array items by country and countryID key-value pairs and store the result to the object values of that generated key as follows.