Trying to refine name search, expand upon the for/if blocks


I'm trying to refine the name/letter search exercise so it does not fall for other words in my text that start with the same letter as my name.

It won't execute...thats not shocking as my comprehension on the details of this exercise haven't completely crystalized. I'm merely parroting right now.

var text= 'physics is so awesome, i really appreciate all it\'s useful and interesting applications and, Justin, implication of everyday sort of, Justin, experiences. Heisenbergs uncertainty principle has certainly, Justin, caught my, Joshua tree, attention.';

var myName='Justin';
var hits=[];

for(var j=0; j<text.length;j++){
    if (text[j] === "J"){
    for (var u=j;u<(myName.length+j);u++){
    if(text[u] === "U"){
  for(var s=u; s<(myName.length+j+u);s++)

I have low confidence the (myName.length+ j+u). I have low confidence in a lot of the code stacking in this particular exercise. To successfully be able to elucidate and expand upon it so I can specify down to the last letter of my name, I would then, hopefully, be able to verbalize the process to understand it. Appreciate any help in advance!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.