title: javascript indexes from codewars
body: <p>I am working on the following codewars problem. The question looks like this:</p>
  <blockquote>
  <p>Instructions</p>
  <p>Write a function capitals that takes a single string (word) as
  argument. The functions must return an ordered list containing the
  indexes of all capital letters in the string.</p>
  <p>Example</p>
  <p>Test.assertSimilar( capitals('CodEWaRs'), [0,3,4,6] );</p>
  </blockquote>
  <p>And my solution is:</p>
  <pre><code>function capitals(word){
    var ara = []
    for(var i = 0; i &lt; word.length; i++){
      if(word[i] == word[i].toUpperCase()){
        ara.push(word.indexOf(word[i]))
      }
    }
   return ara
  }
  </code></pre>
  <p>The code works fine whenever I pass a string to it. The only problem I have is I am getting the same index for a repeated spelling. for instance, <code>capitals(&quot;HeLLo&quot;)</code> returns <code>[0, 2, 2]</code> instead of <code>[0, 3, 4]</code>.
  Is there any way to fix this?</p>