# Length Calculation without decimal

**URL:** <https://community.postman.com/t/length-calculation-without-decimal/32764>\
**Category:** Help Hub\
**Created:** [February 20, 2022, 12:21pm UTC](https://community.postman.com/t/length-calculation-without-decimal/32764 "2022-02-20T12:21:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![minal888](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@minal888](https://community.postman.com/u/minal888)\
**Post date:** [February 20, 2022, 12:21pm UTC](https://community.postman.com/t/length-calculation-without-decimal/32764/1 "2022-02-20T12:21:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![w4dd325](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/w4dd325/32/12436_2.png) [@w4dd325](https://community.postman.com/u/w4dd325)\
**Post date:** [February 20, 2022, 6:39pm UTC](https://community.postman.com/t/length-calculation-without-decimal/32764/2 "2022-02-20T18:39:56Z")

</div>

Hi @minal888

You could use .replace like this;

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

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

```

Output;

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/e/5/e5b9fc10ee83d67e76c606c4c6452b8cb8841a17.png)

---

<div class="post-metadata">

**Author:** ![minal888](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@minal888](https://community.postman.com/u/minal888)\
**Post date:** [February 21, 2022, 2:35am UTC](https://community.postman.com/t/length-calculation-without-decimal/32764/3 "2022-02-21T02:35:50Z")

</div>

Thanks alot. 😊

It worked !!!
