5/7 Search Text for Your Name


/*jshint multistr:true */

var text = "bla blah blah blah Gio balh blah blach blach Gio blah blah blah blah";
var myName = "Gio";
var hits = [];
for (i=0; i === text.length; i++){
if (text[i] === "G"){
for (var j = i; j < (myName.length + i); i++) {

Don't know what I'm doing wrong. Confused and frustrated.


Instead of "i===text.length", you must do "i < text.length". Also, you must change your "hits".



Also, you do not need that last "hits".

Look into your code, and look at the "hits". Change one into my example above, delete the other "hits", put "i < text.length", and it'll be fixed!

Hope it helped!:smiley:


A note to the Editor

  • A word/sentence encapsulated in a pair of double-** will give you
    **Bold** Bold
  • A word/sentence encapsulated in a pair of_underscores_ will give you _Italic_ Italic
  • If you use the \-character, the next-following character is NOT interpreted by the
    Editor, that is how i visualized \_Italic\_
  • The editor will treat a <-character as an opening HTML-Tag

Here I use a h3-tag



Oh ok. Got it. :grin: