How to check if a list contains the element passed in javascript

I want to check if the list returned from the application contains the expected element.Please let me know where am going wrong :

this.verifyOptionsInDrpDwn = async function(){
      var optionList = await drpDwn.all(by.tagName('option')).getText();
      console.log(optionList);
      var expOptions=['a','b','c','d','e','f'];
      for (let i = 0; i < expOptions.length; i++) {
           var bool=optionList.includes(expOptions[i]);
           console.log(bool);
      }
 }
 
 output :
     [
  '1-a',
  '2-b',
  '3-c',
  '4-d',
  '5-e',
  '6-f'
]

false

Answer

includes determines whether an array includes a certain value among its entries. But in your case, you want to check if the elements of that array contain the value of the expOptions.

If you replace var bool=optionList.includes(expOptions[i]); with var bool= optionList.some((a) => a.includes(expOptions[i]));, it should work.