Preserved Topic: IndexOf problem |
|
---|---|
Author | Thread |
Obsessive-Compulsive (I) Inmate From: Preston, Lancashire, England |
posted 04-09-2002 20:21
I'm having problems returning the index of a letter in a string correctly. code: letters = new Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ');
|
Neurotic (0) Inmate Newly admitted |
posted 04-10-2002 03:48
what i would do is this: |
Maniac (V) Mad Scientist From: Belgrade, Serbia |
posted 04-10-2002 19:05
John H, I have tested the code from above and it worked fine. BUT, it won't do what you want; join() function will create string from array elements, but they will be separated by commas and using indeOf() on that string will return number that won't corespond to the actual index in array. You have to strip all commas before using indexOf() function... |
Bipolar (III) Inmate From: London, UK |
posted 04-11-2002 17:18
You could just use join with an empty string seperator... |
Obsessive-Compulsive (I) Inmate From: Preston, Lancashire, England |
posted 04-12-2002 04:03
I went with the string idea (letters = "abcd...") and it's all sorted out now. |