Skip to main content
Inspiring
Sep 6, 2021 3:30 PM UTC
Answered

JS question: does list have value

Good day honorable adobe forum members,

 

I am looking for the method to use to check if a value is in a list

 

i.e.:

 

var list = ["A","B","C"]

if ("a"  in list) {
//dothings
}

 

Hoe does one do this effectively?

 

Thank you in advance for any and all trouble to be taken

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Sep 6, 2021 3:36 PM UTC

Yes, using the indexOf method. See: https://www.w3schools.com/jsref/jsref_indexof_array.asp

 

4 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Sep 6, 2021 3:36 PM UTC

Yes, using the indexOf method. See: https://www.w3schools.com/jsref/jsref_indexof_array.asp

 

Translate
Inspiring
Sep 9, 2021 2:04 PM UTC

Thank you try67, your presence on these boards is a godsend.

 

Thank you very much once more.

Translate
try67
Community Expert
Community Expert
Sep 9, 2021 2:07 PM UTC

You're very welcome!

Translate
Inspiring
Sep 6, 2021 3:30 PM UTC

I see I typed "a" instead of "A" , I hope this doesn't cause confusion (the example should say "A") 

Translate