How to increase environment variable when the value is a number?

How to increase environment variable when the value is a number?
Environment variables do not have variable types as far as I know.

For example, I have an environment variable NumOfLoops = 10.
How can I set the value to: NumOfLoops = NumOfLoops + 1?

Thanks a lot!!!

Hi @Kyortush_13, Welcome to the Community!

Postman stores env variables as strings. In order to perform arithmetic operations on env variables, you need first to parse it as Int then add and again set variable env variable. Please find the below snippet for reference.

Assuming the initial value is stored in variable a.

pm.environment.set("a",parseInt(pm.environment.get("a"))+1);

2 Likes