猿问

为什直接跳过if语句

<script>

function repeat(str) {

let h2 = document.getElementsByTagName('h2');

console.log(h2[0].innerHTML.length);

console.log(str);


h2[0].className = ('body');

h2[0].style.background = "red";


h2[0].onmousemove = function () {

alert('这里');

}


for (var i = 0; i < h2.length; i++) {

let keyword = h2[i].innerHTML.charAt(i);

for (var j = 0; j < h2[i].innerHTML.length; j++) {

if (keyword === str) {

console.log("敏感字" + str + "在" + i + "位置被发现<br>");

}

}

}

return console.log("没有该字");


}

repeat("感冒");



}



</script>


weixin_慕的地4584504
浏览 712回答 0
0回答

慕斯4360584

TKKBTXUDHRXJYGZWAKAUBLYBEAXMWJMVCKWTPOGAQWJNZOYYHFOGTWZLNZZMISBQZQNDJUEYCVZJAGIINCIFQKUXDZSFMJZCTDSTJZCYYSVPDWETCPWSOOIJDGOIDBBHNWAWUGNAASYFIVCXADJZCCQKXTPCYLLYBZWPQPIYOBZFSPJQMZPZMCTPCDRQBQKFVLLYSOSRXOBIRRLNYYZWQNNHAUENYOYPFGKKXKQKQDTTDQGTWWCYKDCDNDWTDMCKNDTGMVPFMDGGWSVPBILHEGWDJZZFANISVOCIOKEVLVHXWDGHAGTDRENDTANKQNZTMSMQWCKQTGAWZDNJIYQQAVRALLYCWTCQNWGJDRWGWZWXEHSOLXQAJMCVIGQXTCWMMPSSLCPVOBOOPBGKQWZJWZCFFSMCFPSPCVYXDJJAGWTZYBKTXWAKXQTXHBRXDZGXHAHKIDTMTINANEAKDTJCFLNUAYUDJPRWMJGGWZLMYFILYBIAXRKMDZFIDZOXANGACSPADTIBSCBUHHNATJGPQTPSSJZOGDMDWJTPCSZYLCCEFCOSYTWIIIIJMMPFUZBYOEUHADKHSIOLHDNOIOGCLVOFYLOVSUDCFFVSBYWAXGZPDAXNKFPFXDEENENVPGLRKAEOCSVIBCIKXTJFDFLYDAZQGSJWMPZSEGDRBQAQNTZMYLCVSYUROTSLBRIDJPJMCERLBVRBEKU

慕斯4360584

PTDKOGFANESTSMCNQFAULVHKDECV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慕5436299

SIFIPDJAHOBIODRTQMQMANXDDXXKHYVCUBHAHVVIFCTXNUGAOOEEOKEHHEOIILNBCPHNNEITPCGHBYLHLWWDNQHPUKOPQBRGUBPANLCAHTUOFFVDDNKHUWHOBMZSZNWNOBIGFYCVPPWWGXKURUVIVIWMQEZTDRLPFMRYWIYYVFWCWJKXARDKJGJAHHBNRULBFFPQNBAGPPFCGWGTVDSYIIPICLKQAWFLFAKQUSFIFRAKOBJTWHRUNKXRRNTOFYLZFZSIIYFMFLIRFCEUYRYOAQBYLENBESTPVEVORUHLTCMFSNQQTWXXFTWCGFWTJZNOICWTTTCCQGPCSCMOUFLJHHNJJCMPAOMJOKAJGKTGWXRVIBXCSOBOLZMMFDAAAQWXXNJGPPZTJEVFAKDMTEHUHEPLXRLVBKROOYHATXQAQTNKZEQQAUYCFSPWMFLQGHRURSVQCZIXNNHXRSVVHBVAQXYLYXTTAHUPSLQDELOOBFOOPBLLERKREUNKHKXSLQNQQWAKAQTMCGMFMNNXREGUREUOROINAZTTCZWZEEOBAQODJDGKUWSVHNNNREYIQZVLSSCDQNCPOURBLFLSPWPFWWQDTNANYEPYFYYHHLRLOUXNNONKRSMFYHLVPZSHKOEEXWGMZXVSIFSULJGTXREBFVZPJGPSCZPZCVBYSCLFWZWCFOCTQQREHFNWGTJDTZQUVFLAWTLORVS

莲_蓶濏__

感冒算两个字吧 charAt(i) 返回的应该是一个吧??? (只要不是特殊的字)

张小喜

三个等号(===)在JS中是既判断值是否相等,又判断类型是否相同。debug一下,看看哪里不同了。
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答