Computer Science Canada Index in Java help |
Author: | Morice [ Thu Mar 30, 2006 3:49 pm ] |
Post subject: | Index in Java help |
Is there an index function in Java script like the one in Turing tat i can use for a hangman game? |
Author: | wtd [ Thu Mar 30, 2006 3:59 pm ] |
Post subject: | |
Javascript is not Java. Also, for those not familiar with Turing's "index" function, please provide a description of what you wish to accomplish. |
Author: | Morice [ Thu Mar 30, 2006 4:02 pm ] |
Post subject: | |
ok. I want to see if in a word is ther a letter tat im searching for. |
Author: | Corvillus [ Thu Mar 30, 2006 5:52 pm ] | ||
Post subject: | |||
I'd guess you're looking for the String.indexOf() method, which returns the index of the first occurence of either a given character or a given string within a string, or -1 for no occurence. For example:
|
Author: | [Gandalf] [ Thu Mar 30, 2006 7:48 pm ] | ||
Post subject: | |||
Or if you're talking about JavaScript...
The method works the exact same way as the Java example posted by Corvillus. |