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++) {
    if (>0) {
  return capArray;

thanks in advance.

.charAt() (notice brackets?);


thank you so much