Removing spaces from variables

Hello, how can I replace a character in a collection variable? I have to pass value from first request to another.

Response value of the first request is a string, always with the same format of 2 letters followed by space and random number (letters and numbers are random) e.g.:

"key": "XX 233"

I set a collecion variable by using:

const jsonData = pm.response.json();
pm.collectionVariables.set("test_var", jsonData.key);

The next request requires this variable in format “XX233”, so I have to get rid of space in the string. I’m new to Postman, so I hope I’m asking in a correct category.

Postman uses JavaScript under hood.

Have a look at the following;

Great, it’s working, thanks