0

atm I'm learning JS/Angular and making project using these technologies and I need some help here.

table = ['a', 'b', 'c', 'a'];

if(table.includes('a' > 2))  #its not working, idk how to make it
{
   console.log("We have 2 the same atributes in our table");
}

How to make it happen?

can1
  • 49
  • 1
  • 8

1 Answers1

0

You can filter the array and check it's length

if(table.filter(item => item === 'a').length > 1) {

}
Suren Srapyan
  • 66,568
  • 14
  • 114
  • 112