Garmaine Staff asked 1 year ago

In the map function… if the arrayOfObjects was not "" but was say "obj.animal" or obj.anything… I don't want to have to change that line for every array of objects I use the function on that has a different property name. Ultimately the function should take in an array of objects then return an array of values and check for duplicates then return unique array. Thanks in advance. Also I am new and I feel like I shouldn't be using two return statements within one function so any tips much appreciated.

const arrObj = [
  { car: "BMW" },
  { car: "Honda" },
  { car: "BMW" },
  { car: "BMW" },

const duplicates = (arrayOfObjects) => {
  var finalArray = => {
  const uniqueSet = new Set(finalArray);
  const uniqueArr = [...uniqueSet];
  return uniqueArr;