Cannot read property 'search' of undefined

Cannot read property 'search' of undefined
0

#1

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.


#2

.charAt() (notice brackets?);


#3

duh.

thank you so much