Skip to main content
Inspiring
September 6, 2021
Answered

JS question: does list have value

  • September 6, 2021
  • 2 replies
  • 610 views

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 has been closed for replies.
Correct answer try67

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

 

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 6, 2021

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

 

Inspiring
September 9, 2021

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

 

Thank you very much once more.

try67
Community Expert
Community Expert
September 9, 2021

You're very welcome!

Inspiring
September 6, 2021

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