# Array.includes() method not working

**URL:** <https://forums.knack.com/t/array-includes-method-not-working/13859>\
**Category:** Ask Developers\
**Created:** [March 2, 2023, 4:25pm UTC](https://forums.knack.com/t/array-includes-method-not-working/13859 "2023-03-02T16:25:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathaniel](https://avatars.discourse-cdn.com/v4/letter/n/ba8739/32.png) [@Nathaniel](https://forums.knack.com/u/Nathaniel)\
**Post date:** [March 2, 2023, 4:25pm UTC](https://forums.knack.com/t/array-includes-method-not-working/13859/1 "2023-03-02T16:25:36Z")

</div>

**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");
> 
> ```

**Problem:**  
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.

---

<div class="post-metadata">

**Author:** ![Nathaniel](https://avatars.discourse-cdn.com/v4/letter/n/ba8739/32.png) [@Nathaniel](https://forums.knack.com/u/Nathaniel)\
**Post date:** [March 3, 2023, 3:51am UTC](https://forums.knack.com/t/array-includes-method-not-working/13859/2 "2023-03-03T03:51:04Z")

</div>

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.
