Note that if the character you want to find occurs multiple times in the string, this code will only find the position of the first occurrence. If you want to find the position of all occurrences of the character, you can use a loop to iterate over the string and find each position in turn. Also, if the character you want to find is not present in the string, the indexOf method will return -1, so you will need to add error handling to handle this case.