Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Scott Mcgee on March 19, 2018 at 2:29 pm

    Hey Guys,

    I’ve seen a few versions of this but not the way I want to use it and struggling to tweak it to work.

    I have two arrays.

    j = [“BL”, “CF”, “LS”]
    k = [“Bristol”, “Cardiff”, “Leed”]

    I want a for loop to go through the Array and if the indexOf matches my compname it returns the other arrays value.

    Example

    Compname = BL-TEST

    The array will find it is j[0];
    and will return k[0];

    I can’t seem to get this to work at all.

    Scott Mcgee replied 8 years, 5 months ago 1 Member · 1 Reply
  • 1 Reply
  • Scott Mcgee

    March 19, 2018 at 2:56 pm

    Not sure how I got this to work, but I’m taking it as a win.

    Anyone who might be struggling with this here’s how I got it to work.

    input = thisComp.name;

    var myArray = [“BL”, “CF”, “LS”];
    var myResult = [“Bristol”,”Cardiff”,”Leeds”]

    result = null;
    for (var i = 1; i <= myArray.length; i++){
    if (input.indexOf(myArray[i]) > -1){
    result = i;
    break;
    }
    }
    myResult[result]

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