JSFiddle - React, Tailwind, and code Playground

by Arvind Pal

JavaScript

const array = [{
    name: 'Joe',
    age: 17
  },
  {
    name: 'Bob',
    age: 17
  },
  {
    name: 'Tom',
    age: 25
  },
];

const distinctAges = [...new Set(array.map(a => a.age))];

console.log(distinctAges)