--

Another option can be reduce.

%dw 2.0

output application/json

fun sumOfDigits(number) = number reduce ((item, accumulator) ->

accumulator+item

)

---

sumOfDigits(498) as Number

--

--

Shyam Raj Prasad
Shyam Raj Prasad

Written by Shyam Raj Prasad

Engineering Leader at Tricon Infotech Private Limited | Mulesoft Certified Developer and Architect

No responses yet