โ02-15-2022 10:12 AM
Hi there,
I have an array that has negative decimal values. how can I make all the values positive, if theres one?
Thanks
Manohar
โ02-15-2022 10:23 AM
@manohar You can use the map Array function:
$array.map(x => Math.abs(x))
โ02-15-2022 11:08 AM
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
โ02-15-2022 11:21 AM
Assuming jsonPath($, โ$[โinvoice-chargesโ][*].totalโ)
returns an array:
jsonPath($, โ$[โinvoice-chargesโ][*].totalโ).map(x => Math.abs(x))
โ02-15-2022 11:35 AM