# Cannot find method of adding two environment variables together to get result i.e. 4 +7 = 11

**URL:** <https://community.postman.com/t/cannot-find-method-of-adding-two-environment-variables-together-to-get-result-i-e-4-7-11/31266>\
**Category:** Help Hub\
**Tags:** tests, variables\
**Created:** [January 5, 2022, 11:03am UTC](https://community.postman.com/t/cannot-find-method-of-adding-two-environment-variables-together-to-get-result-i-e-4-7-11/31266 "2022-01-05T11:03:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pabloh1](https://avatars.discourse-cdn.com/v4/letter/p/3d9bf3/32.png) [@pabloh1](https://community.postman.com/u/pabloh1)\
**Post date:** [January 5, 2022, 11:03am UTC](https://community.postman.com/t/cannot-find-method-of-adding-two-environment-variables-together-to-get-result-i-e-4-7-11/31266/1 "2022-01-05T11:03:46Z")

</div>

_My question_:  
I am trying to add two environment variables together to get a result i.e. 4 + 7 expecting 11, however when I put the + sign in it simply merges them to give a result of 47.

I have a similar requirement to confirm that variable a - variable b also equals 11. I can get this working with this test below

pm.test (“Check balance correct”, function () {  
var jsonData = pm.response.json();  
pm.expect(jsonData[0].id).to.eql(pm.environment.get(“id1”)-(pm.environment.get(“id2”)));

_How I found the problem_:  
I am trying to confirm that after in a get have been obtained and written to the environment variables, followed by a Post that will reduce one value and increase another that the result that is sent in the response body matches that expected.

_I’ve already tried_:  
I have tried putting the + inside “” and () but this does not work, I have also tried Add, none of which work.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [January 5, 2022, 2:20pm UTC](https://community.postman.com/t/cannot-find-method-of-adding-two-environment-variables-together-to-get-result-i-e-4-7-11/31266/2 "2022-01-05T14:20:11Z")

</div>

Hey @pabloh1

You need to use `parseInt()` here to convert the variable, which is stored as a `string`, to an `int`.

This is an example of using the console to log out the sum value.

```auto
console.log(parseInt(pm.environment.get("id1")) + parseInt(pm.environment.get("id2")))

```
