how to get index of array in javascript
<p>I have a problem in obtaining the index, if in an array there are some similar words but with a different index position and when I select one of the word, the index that I get is not from words but from which I select the same word in previous position</p>

<p>for example I have a sentence:</p>

<p>The Harvest is <strong>the</strong> process of gathering</p>

<p>the bold word is the word that I choose..</p>

<p>this is my code:</p>

<pre><code>var str = "The Harvest is the process of gathering";
var myArray = str.split ("");
var Select  = "the";
</code></pre>

<p>and I have a function like this:</p>

<pre><code>function getIndex (arrayItem, item) {
   for (var x = 0; x &lt;arrayItem.length; x + +) {
    if (arrayItem [x] == item) {
     return x;
     }
   }
   return -1;
   }

var idx = getIndex (myArray, Select);
</code></pre>

<p>how to get that index?</p>
