What`s wrong?


var text="ahmed ahmed ahmed ahmed ahmed ahmed";/*jshint multistr:true */
var myName='ahmed';
var hits=[];
for(var i=0; i<myName.length;i++){
if( myName[i]==='a')


Well this should print


does it? Also it is not what the exercise asks to do.


it does, what Specifically it asks :sweat_smile:


Well at the moment you go through your name, letter by letter and when you encounter an "a" you print y otherwise you print a n. Depending on the actual exercise you should rather go through your text instead, again letter by letter (for loop). And when you encounter the first letter of your name ("a") you should do enter another for loop that goes from the current position to the current position + the length of your name and adds any letter that it traverses to the hits array using the .append() method on hits e.g. hit.append(2) would add a 2 at the end of hits.


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