I finally found out the problem with my js. One must be sure to have the correct String being pushed
var text=":LJSDFkl as;jdfk Jonathan LKSJFDkjasfjioodsj kdjfoa[jsdif oajdfioasdjfjkads ioah fidha oiioreah iodsajfoi;dhadoi g Jonathan ] alksjdfkasjdfiojadsiojfioajsdifojsdaiojfioajsdofijaoispjf Jonathan";
var myName = "Jonathan";
var hits = [];
for (var i = 0; i < text.length; i++) {
if (text[i] === myName[0])
{
for (j = i; j <= i + myName.length; j++)
{
hits.push(text[j]);
}
}
}
console.log(hits);
No comments:
Post a Comment