title: Javascript: get the place of a string then generate random text
body: <p>I have 3 example sentence here wherein names are dynamically generated.</p>
  
  <p>Is it possible to get the place of this names, like getting that it is after the word "<strong>I'm</strong>" and before <strong>,</strong></p>
  
  <pre><code>&lt;p id="demo"&gt;Hi, I'm Johnny Bravo, how can i help you?&lt;/p&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;p id="demo"&gt;Hi, I'm Martir de Kuts, how can i help you?&lt;/p&gt;
  </code></pre>
  
  <p>or</p>
  
  <pre><code>&lt;p id="demo"&gt;Hi, I'm Jayson Dee, how can i help you?&lt;/p&gt;
  </code></pre>
  
  <p>After getting the place of the name on the sentence. What I am going to do next is to generate a random name on it but i have a working code on it so i only need to determine is to get the place of the name based on my example.</p>
  
  <p>****** <strong>UPDATE to my POST</strong> ******</p>
  
  <p>This is what I am trying to achieve, now its working and thanks for helping me.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var target = document.getElementById('demo');
  var text = target.textContent;
  var ArrayName = ['Vincent', 'Marie', 'Paul', 'Virginie'];
  var randomIndex = Math.floor(Math.random() * ArrayName.length); 
  var randomElement = ArrayName[randomIndex];
  var split1 = text.split(',');
  var split2 = split1[1].split("I'm ")
  split2[1] = randomElement;
  split1[1] = split2.join("I'm ");
  target.textContent = split1.join(',');</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;p id="demo"&gt;Hi, I'm Johnny Bravo, how can i help you?&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>