title: How to find a "(a substring)" in a given "text" without using Regular expressions?
body: <p>Recently I was asked in an interview, where the interviewer asked me this above question. </p>
  
  <p>I was surely perplexed and answered him by using a for loop implementation where </p>
  
  <ol>
  <li>we would find the length of the given "text" (using JavaScript) ... <code>str.length()</code> ...  </li>
  <li>we would take the first element of the "pattern" and find that in the "text". </li>
  <li>If found we would increment the array .. As strings are stored as array in JavaScript ..   </li>
  <li>And we would find the "(a substring)" in similar way.. </li>
  </ol>
  
  <p>know this might be wrong way , but can anyone suggest a better way ? Thank you :-)</p>