# Setting up random words in for array and adding as environment variable to use for other requests

**URL:** <https://community.postman.com/t/setting-up-random-words-in-for-array-and-adding-as-environment-variable-to-use-for-other-requests/11883>\
**Category:** Help Hub\
**Created:** [April 11, 2020, 5:54am UTC](https://community.postman.com/t/setting-up-random-words-in-for-array-and-adding-as-environment-variable-to-use-for-other-requests/11883 "2020-04-11T05:54:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aditya\_Keshavamurthy](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@Aditya\_Keshavamurthy](https://community.postman.com/u/Aditya_Keshavamurthy)\
**Post date:** [April 11, 2020, 5:54am UTC](https://community.postman.com/t/setting-up-random-words-in-for-array-and-adding-as-environment-variable-to-use-for-other-requests/11883/1 "2020-04-11T05:54:24Z")

</div>

Hi,  
have a doubt with setting up random values to environment level and use it.  
Actually I wanted to add a random word in place of name and namekey and set it in environment level. So I have attached the code. But it’s going as undefined error always. I am not if I can do this with the below code. So my body is always dynamic so I want to generate random words/word, whenever it runs and set it and use it for other request. So that always I can have new values without input.Thanks in advance,

**POST body :**

[  
{  
“name”: “{{categoryName}}”,  
“nameKey”:“{{categorynameKey}}”  
}  
]

Code : **Pre-request Script**

var random1=“{{$randomLoremWords}}”;

var random2=“{{$randomLoremWord}}”;

var categoryName=pm.environment.get(“name”) + random1

console.log(categoryName);

var categorynameKey=pm.environment.get(“nameKey”) + random2

console.log(categorynameKey);

pm.environment.set(“caetegoryName”, data[0].categoryName);

pm.environment.set(“categorynameKey”,data[0].categorynameKey);
