0
我是JavaScript的新手,並在下面的代碼中找到字符串「Craig」並將其推入新的數組「Hits」中。無法將某些字符串插入到數組中
var text = "Hey, how are you \ doing? My name is Emily.\ My other friends name is Craig. My friend Craig is learning JavaScript";
var myName = "Craig"
var hits = [];
for(var i = 0; i < text.length; i++){
if(text[i]=== "C"){
for(var j = i; j < myName.length; j++){
hits.push(j);
}
}
}
謝謝你的提示雲。 – 2015-02-23 04:35:28