# Day 26 challenge -Script added correctly | TypeError: Cannot read property 'find' of undefined

**URL:** <https://community.postman.com/t/day-26-challenge-script-added-correctly-typeerror-cannot-read-property-find-of-undefined/25066>\
**Category:** Help Hub\
**Tags:** tests\
**Created:** [June 21, 2021, 8:27pm UTC](https://community.postman.com/t/day-26-challenge-script-added-correctly-typeerror-cannot-read-property-find-of-undefined/25066 "2021-06-21T20:27:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kkalpana55](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kkalpana55/32/8190_2.png) [@kkalpana55](https://community.postman.com/u/kkalpana55)\
**Post date:** [June 21, 2021, 8:27pm UTC](https://community.postman.com/t/day-26-challenge-script-added-correctly-typeerror-cannot-read-property-find-of-undefined/25066/1 "2021-06-21T20:27:56Z")

</div>

Day 26th -parse html response-I am able to create an array and store the values of the response in an array it passes individually when i run the test case. But when i run it in submit the test case gets failed stating that cannot read property ‘find’ of undefined. Can anyone help me out .

![image](https://us1.discourse-cdn.com/getpostman/original/3X/b/e/befff156831bdbcaa864caeaa5d2c21c531e684c.png)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/a/3/a381d44f3c577049433760d0ec906a9110d62964.png)

---

<div class="post-metadata">

**Author:** ![carson-hunter-postma](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/carson-hunter-postma/32/9262_2.png) [@carson-hunter-postma](https://community.postman.com/u/carson-hunter-postma)\
**Post date:** [July 25, 2021, 10:46pm UTC](https://community.postman.com/t/day-26-challenge-script-added-correctly-typeerror-cannot-read-property-find-of-undefined/25066/2 "2021-07-25T22:46:21Z")

</div>

Hi @kkalpana55,

Can you double check that your collection variable is being created and that the value is persisted both the “initial value” and “current value” columns?

When I recreated your solution, I got a different error: “JSONError: No data, empty input at 1:1 ^”. After I persisted the “links” collection variable’s value to be in both the initial and current columns, the validation test passed. However, when I delete the collection variable altogether, I get the error you’re showing, so it seems like maybe your collection variable isn’t being created. Hope this helps!

---

<div class="post-metadata">

**Author:** ![kkalpana55](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kkalpana55/32/8190_2.png) [@kkalpana55](https://community.postman.com/u/kkalpana55)\
**Post date:** [July 26, 2021, 7:49pm UTC](https://community.postman.com/t/day-26-challenge-script-added-correctly-typeerror-cannot-read-property-find-of-undefined/25066/3 "2021-07-26T19:49:10Z")

</div>

Hi @carson-hunter-postma yes its was not creating I changed few steps now its not getting error thank you very much

---

<div class="post-metadata">

**Author:** ![spaceflight-astronom](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@spaceflight-astronom](https://community.postman.com/u/spaceflight-astronom)\
**Post date:** [February 4, 2023, 11:36pm UTC](https://community.postman.com/t/day-26-challenge-script-added-correctly-typeerror-cannot-read-property-find-of-undefined/25066/4 "2023-02-04T23:36:46Z")

</div>

Hi! Could you expain why do you use JSON.stringify in this case: pm.collectionVariables.set(‘links’, JSON.stringify(links)) ?  
When variable “links” is already an array? Why would you make it as a string?  
But I see that when setting this array to collection variable Postman does not see it as array. How come?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [February 5, 2023, 2:08pm UTC](https://community.postman.com/t/day-26-challenge-script-added-correctly-typeerror-cannot-read-property-find-of-undefined/25066/5 "2023-02-05T14:08:58Z")

</div>

@spaceflight-astronom

You need to stringify() arrays when storing them as collection\environment variables and then JSON.parse() them when retrieving or they end up being treated as strings not arrays.

It’s the same principle when parsing the response. If you didn’t parse it, and just retrieved the body it would just be a JSON object wrapped in a string.

---

<div class="post-metadata">

**Author:** ![spaceflight-astronom](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@spaceflight-astronom](https://community.postman.com/u/spaceflight-astronom)\
**Post date:** [February 5, 2023, 6:52pm UTC](https://community.postman.com/t/day-26-challenge-script-added-correctly-typeerror-cannot-read-property-find-of-undefined/25066/6 "2023-02-05T18:52:42Z")

</div>

Great, thanks. I never thought of these specifications for Postman 🙂
