const array = [{
        productname: "productname1",
        category: "category1"
    },
    {
        productname: "productname2",
        category: "category2"
    },
    {
        productname: "productname3",
        category: "category3"
    },
    {
        productname: "productname4",
        category: "category1"
    },
    {
        productname: "productname5",
        category: "category2"
    }
]
I want to get an output where I can get all the categories without having duplicates
I tried using map and filter but my output was:
["category1" "category2", "category3","category1","category2"]
my desired output is
["category1" "category2", "category3"]
How can I achieve this?
 
    