AnsweredAssumed Answered

How to slice array in Arcade?

Question asked by recurvata on Jul 9, 2019
Latest reply on Jul 9, 2019 by recurvata

I have an Arcade expression that I want to use for labeling. If the label field (named Label) is two words or less, I return the field. This works fine. But if the Label is more than two words, it should return the first two words, followed by a newline, then the rest of the words. In Python, this would be something like lbl_array[:2] + '\n' + lbl_array[2:]. But I can't figure out or find how to slice Arcade array elements like that. I could use a for loop to construct the label, but there should be a way to use the indexes.

 

var lbl = $feature["Label"]

var lbl_array = Split(lbl, ' ')

if (count(lbl_array) < 3) {

    return lbl }

else {

?? }

Outcomes