Where I improve this code?


#1

/*jshint multistr:true */

var text = 'Hi,I am joy.Joy is a programmer.';
var myName = "JOY";
var hits = [];
for (var i = 0; i < text.length;){
if (text[i] === myName[i]) {
for(var j=i; j < myName.length;j=j+1){
hits.push(myName[j]);
console.log(myName[0]);
}
}
}


#2

Put a space between HI, I am joy.{SPACE}Joy is a programmer.


#3

If myName = "JOY", will the 1st for loop be able to pull it from the text string?


#4

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