in Unity Javascript?

I'm trying to get a count of the number of instances of a char in a string.

Is there any way to get this to work in Unity's JS?

var amtOfXinString : int ="x");

You'd call IndexOf in a loop. Something like (untested):

int count = 0;
int i = stringToSearch.IndexOf("X");
while (i > 0)
  i = stringToSearch.IndexOf("X",i+1);