Length Calculation without decimal

Hi,

I want to calculate length of one of the field of JSON request. Value of that field is number with decimal.

Can someone please help me how can i calculate the length of the number without decimal.
Suppose if value is 99.99. I want the total length as 4 not 5.

I tried to use length function but it is including decimal also in the length.

Hi @minal888

You could use .replace like this;

const val = pm.response.json().your.value;

let newVal = val.replace('.', '');
console.log(newVal);
console.log(newVal.length);

Output;

Thanks alot. :blush:

It worked !!!

1 Like