Reasons why your current solution fails:
javascript is case-sensitive you trying to call String.IndexOf won't work, instead you have to write it as indexOf.
same reason as previous list entry, SubString should be written as substring, in the method you are using it seems like you are looking for substr (because of your arguments).
Alternative solutions
There are several ways to simplify your method of getting the text inbetween [and ], I wrote three examples below.
text.substring (text.indexOf ('[')+1, text.lastIndexOf (']'));
text.substr (n=text.indexOf('[')+1, text.indexOf (']')-n);
text.split (/\[|\]/)[1];
text.match (/\[(.*?)\]/)[1];
"i HATE you"or"[i LOVE you]"?