Hi all,
A HubL puzzle:
Take a long integer, put each digit into an array, output the average.
E.g. input is 6314095485.
Array becomes [6, 3, 1, 4, 0, 9, 5, 4, 8, 5]
Average = 4.5
How is this written in HubL?
Many thanks!
Rich
//starting number{% set num = 6314095485 %}//convert it to string
{% set numAsString = num+"" %}//convert the string to a list and add each number
{% set numSum = numAsString|list|sum %}//sanity check; get the length of the list
{% set numCount = numAsString|list|length %}//division; use the float filter to keep from rounding up/down to integer
{{(numSum|float / numCount)}}
If this answer helped, please, mark as solved ![]()
tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.
Drop by and say Hi to me on slack.
Hi Tim,
This is perfect in every way. Thanks so much!
Rich