Cannot read property 'search' of undefined

Hoping someone can help me understand this.

All I’m trying to do is search a string for capital letters and record the character number that those appear in the string.

Here’s the relevant code:


function captureCaps(stringWithCaps) {
  var testStr= /[A-Z]/g;
  var pretendString=stringWithCaps;
  var testChar="";
  for (i=0; i<pretendString.length; i++) {
    testChar=pretendString.charAt[i];
    if (testChar.search(testStr)>0) {
      capArray.push(i);
    }
  }
  return capArray;
}

thanks in advance.

.charAt() (notice brackets?);

duh.

thank you so much