任何幫助將不勝感激:我只是不能繼續前我弄清楚我做錯了什麼..搜索文本的名稱(javascript)
我正在尋找一個文本名稱與一個for
循環,然後試圖將這些字母推入數組。出於某種原因,這不是推動,我不知道我在做什麼錯誤..仍然是一個新手.. thx的幫助!
var text = "Code it out bro, it will just get Zane Zane Zane better
from here, especially after your familiar with the various
frameworks..yeah man...";
var hits = [ ];
var nameZane = "Zane";
for (i=0; i < text.length; i++)
if (i === "Z"){
for (j=i; j < nameZane.length + i; j++){
hits.push(text[j])}
}
if (hits.length === 0){
console.log("Couldn't find " + nameZane)}
else{
console.log(hits)}
何必太多這樣做。只要使用正則表達式這個 –
將'i ===「Z」'永遠是_true_? – Satpal
它應該是'text [i] ===「Z」' – gurvinder372