여기에 갇혀 있습니다. 내 웹 페이지의 문단은 id="history"
이고 문단은 myArray
이고, myArray[i]
과 일치하면 (예 : 10
) 다음과 같은 기능이 필요합니다. jQuery를 나중에 배울 것이므로 제안하지 마십시오.'푸시'메트로로 채워진 빈 배열을 반복합니다.
var myArray = [];
function myFunction(){
// do something
myArray.push(8);
myArray.push(10);
}
function myOtherFunction(){
document.getElementById('history').innerHTML = myArray;
}
function myAnotherFunction(){
for (var i = 0; i<=myArray.length; i++){
if (myArray[i] === 10){
//do something
}
}
}
루프의 상한값이 1입니다. –
배열 항목이 실제로 10 일 경우 어떻게해야합니까? –
코드가 정상적으로 보입니다. 뭐가 문제 야? – freakish