所以找到一个字,我工作的一个for循环,将确定我的名字,安德鲁,并将其推到一个数组,但有什么不对的地方循环在一个字符串
/*jshint multistr:true */
var text = ("Andrew is really awesome and Andrew should be working on the project, but there is honestly nothing for Andrew to do.");
var myName = ("Andrew");
var hits = [];
for (var i = 0; i < text.length; i ++) {
if (text[i] === "A") {
for (var j = i; i + nyName.length; i ++) {
hits.push(text[j]);
}
}
}
另外,第二个循环在到达myName的末尾时应该停止。
我想你的意思是(i-j)
svk
2013-04-24 18:38:38