How to add suffix like "st", "nd", or "rd" depending on number in JSONata?
I want to achieve something like this:
- If number is 1, output "1st"
- If number is 2, output "2nd"
How to add suffix like "st", "nd", or "rd" depending on number in JSONata?
I want to achieve something like this:
2
Answers
You can use conditionals and then string concatenation like shown in the example code below.
You can declare this custom function on top of your JSONata expression and use it like so:
Playground link: https://jsonatastudio.com/playground/4e1ae089