所以,我正在研究一个“for”循环,它将识别我的名字 Andrew,并将其推送到一个数组中,但它有问题
/*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 的末尾时停止。