Array.includes() method not working

Here is the code I am having trouble with:

//declaring some vars
var isMetalSign = false;
var isMicroperforated = false;
var isBrochures = false;
var isBrochureHolder = false;
var isRollUp = false;

//promoMaterials is an array that has been set to a list of materials - this code is not shown here 
isMetalSign = promoMaterials.includes("Metal Sign");
isMicroperforated = promoMaterials.includes("Microperforated Decal");
isBrochures = promoMaterials.includes("Brochures");
isBrochureHolder = promoMaterials.includes("Brochure Holder");
isRollUp = promoMaterials.includes("Roll Up");

The includes method works on the first match, but then even if the string is in the array, after the first match, it will return false. Example, promoMaterials = [“Metal Sign”, “Brochures”], the result will be that isMetalSign = true, but isBrochures = false.

Sample Console Output:
promoMaterials: Metal Sign, Microperforated Decal, Brochures, Brochure Holder, Roll Up
isMetalSign: true
isMicroperforated: false
isBrochures: false
isBrochureHolder: false
isRollUp: false

I have tried:

  • I have tested this code in Node.js interpreter and I get the expected results.

  • Used includes method with the start parameter set to 0. Array.includes(“string”, 0);

Any help will be greatly appreciated.

Ignore. This was an oversight on my part. I missed that some elements in the array had extra white space at the beginning. Using trim before pushing the elements into the array resolved my issue.