I’m trying to use the probability evaluation to look for a value in an array and only select that item if the value is found. I’m running into an issue creating the variable of the array.

['airport','train station','bus stop'].indexOf('airport') 

returns a positive 1 but

travelarray = ['airport','train station','bus stop']
travelarray.indexOf('airport') 

returns -1

Ultimately, I’d have a list like this:

situation 
  generic situation
  something that applies to airport location^[travelarray.indexOf(location) >= 0 ? 100 : 0]
  something that applies to bus station location^[travelarray.indexOf(location) >= 0 ? 100 : 0]

So, first, how do I create a variable array in perchance?

Second, is my if statement for the probability evaluation correct? There will be multiple items that fit each location, and I want generic situations to also be eligible regardless of location.

Thanks!

  • BluePower
    link
    fedilink
    39 months ago

    @shantismurf Try wrapping up the brackets of the array values with another set of brackets, like this:

    travelarray = [[‘airport’,‘train station’,‘bus stop’]]

    Also, you can use location.evaluateItem to get a direct string of the value, so it’ll be a valid filter.