-1

I have an array that has multiple months of occurrence so I did this method to remove these occurrences but no truthly results, I don't know what my mistake I made

let tab1:any=[month];
  let tab2:any=[]
  let tab3:any=[]
for (let index = 0; index < tab1.length; index++) {
   tab2.push(tab1[index]);
   
     if(tab2 !== tab1[index])
     {
      tab3.push(tab2  );

     }
     
   
  console.log("tab3 :",tab3)
}
  • Can you provide the expected Input and Output because, question is not clear, if you want an unique month list, you can filter out the duplicate value. – Abhishek Kumar Pandey May 02 '21 at 04:17

1 Answers1

1

You can use set Operator:

months = [...new Set(tab1)];
Adnan
  • 814
  • 12
  • 38