Using Arcade I have created narrative conventions for different fields in my dataset. I would like to concatenate these features into a sentence separated by a comma, based on their presence in each feature. That's simple enough, but I would like to place 'and' after the comma before the last item in the list, if that comma is even necessary.
.e.g., a feature is populated for Transit. but not Car, Bike, or Ped, so the concatenated sentence would read "...people taking transit."
or
.e.g., a feature is populated for Car and Ped, but not Bike or Transit, so the concatenated sentence would read "...people driving and people walking."
or
e.g., a feature is populated for Car, Bike, Ped, and Transit, so the sentence would read "... people driving, people riding bicycles, people walking, and people taking transit."
var Car = IIF(IsEmpty($feature.Car),"",'people driving')
var Bike = IIF(IsEmpty($feature.Bike),"",'people riding bicycles')
var Ped = IIF(IsEmpty($feature.Ped),"",'people walking')
var Transit = IIF(IsEmpty($feature.Transit),"",'people taking transit')<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I get the feeling this can be done through an array, but I haven't been able to figure out the logic.