Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Check if Variable is equal to one of multiple values. (ex : 1 OR 4)

  • Check if Variable is equal to one of multiple values. (ex : 1 OR 4)

    Posted by Lucas Piazzini on August 13, 2022 at 5:35 pm

    Hello ! I have a menu and need my expression to check if its value is, for example, 1 OR 4 OR 7.
    Unfortunately, none of the methods I’ve seen online work, which are :
    if(menu == 1|| 4 || 7)

    and

    var array = [1,4,7];
    if(array.includes(menu))

    None of these give me a true result when menu is equal to one of them, all I have are false returns. Do you have any ideas?

    Sincerely, Lucas

    Lucas Piazzini replied 4 years, 1 month ago 2 Members · 2 Replies
  • 2 Replies
  • Paul Conigliaro

    August 13, 2022 at 6:11 pm

    The syntax for multiple OR conditions would need to be something like:

    if(menu==1 || menu==4 || menu==7)

    Your idea of using includes() is spot on. But you might have to add .value to your variable if it’s pointing to a control like a menu. So it might looks something like:

    let arr = [1,4,7];
    arr.includes(menu.value);
  • Lucas Piazzini

    August 13, 2022 at 7:16 pm

    Oooh indeed, it works ! Thank you so much!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy