How to find the first target element in an array

Hi all dears,

currently i need to find a specific fruit and give it a value, however the fruit name in the array may be duplicate and i need to give value only for the first one appeared the array:

For example:

Rule Inputs:

fruits(5 items)

[1] [fruitName:apple, price:""]

[2] [fruitName:banana, price:""]

[3] [fruitName:banana, price:""]

[4] [fruitName:peach, price:""]

[5] [fruitName:peach, price:""]

 

These data will be shown in a grid in interface, and i need to give the first banana([2]) 's price a value, but leave [3] banana's price as empty. 

should be like this:

[1] [fruitName:apple, price:""]

[2] [fruitName:banana, price:"100"]

[3] [fruitName:banana, price:""]

[4] [fruitName:peach, price:""]

[5] [fruitName:peach, price:""]

i created  local!fruitFlag = "banana" to map the fruit name and now i can give both banana's price value by using forEach(). so how can i only give the first one value?

millions thanks for help!

  Discussion posts and replies are publicly visible