Search found 5 matches

by luigihmtz
May 5th, 2014, 4:12 pm
Forum: Scripts Discussion
Topic: IndexOf problem
Replies: 10
Views: 29474

Re: IndexOf problem

OK, I came out with this: feed = "Banana"; fruits = [ ]; fruits[0] = "Banana"; fruits[1] = "Orange"; fruits[2] = "Apple"; fruits[3] = "Mango"; for (var i=0; i<fruits.length; i++) { if ( feed == fruits[i] ){ idx = i; break; } else { 0 } } Not quite el...
by luigihmtz
May 5th, 2014, 3:15 pm
Forum: Scripts Discussion
Topic: IndexOf problem
Replies: 10
Views: 29474

Re: IndexOf problem

Hopefully this should make my point clearer: For instance, this expression would cause an error in AE, as it shows Undefined because the variable contains an array. If you try this e.g. on "web" javascript, it won't break: fruits = ["Banana", "Orange", "Apple"...
by luigihmtz
May 5th, 2014, 1:37 pm
Forum: Scripts Discussion
Topic: IndexOf problem
Replies: 10
Views: 29474

Re: IndexOf problem

IndexOf is a string function and doesn't work with arrays anywhere. Sorry, my bad, I mixed up stuff. I do know that indexOf has a string-only input parameter but, at least in regular javascript, it is NOT a string-only method. What I mean is that you can use either an array of strings or a mere str...
by luigihmtz
May 5th, 2014, 1:35 pm
Forum: Scripts Discussion
Topic: IndexOf problem
Replies: 10
Views: 29474

Re: IndexOf problem

IndexOf is a string function and doesn't work with arrays anywhere. Sorry, my bad, I mixed up stuff. I do know that indexOf has a string-only input parameter but, at least in regular javascript, it is NOT a string-only method. What I mean is that you can use either an array of strings or a mere str...
by luigihmtz
May 4th, 2014, 1:49 am
Forum: Scripts Discussion
Topic: IndexOf problem
Replies: 10
Views: 29474

Re: IndexOf problem

Hello, everyone. It turns out that the indexOf method works fine with strings, but it fails when used with arrays, as opposed to regular javascript, which supports either. For instance, this expression would cause an error in AE, as it shows Undefined because the variable contains an array. If you t...