Forum Discussion

manohar's avatar
manohar
Contributor
4 years ago

Math.absolute on array element

Hi there,

I have an array that has negative decimal values. how can I make all the values positive, if theres one?

Thanks
Manohar

5 Replies

    • manohar's avatar
      manohar
      Contributor

      Hi @rohithmadhavan. thanks for that.

      I actually should have added my array that I want to convert. how can I apply yours to below one?

      jsonPath($, “$[‘invoice-charges’][*].total”)

      Thanks
      Manohar

      • rohithmadhavan's avatar
        rohithmadhavan
        Employee

        Assuming jsonPath($, “$[‘invoice-charges’][*].total”) returns an array:

        jsonPath($, “$[‘invoice-charges’][*].total”).map(x => Math.abs(x))