내 코드가 작동하지 않도록 js에서 작업하는 것이 처음입니다.
내 코드는 다음과 같습니다.
let output = document.getElementById("output");
let addfruit;
let fruitList = [];
let howManyTimes = prompt("how many fruit to want to add?");
for (let index = 0; index < howManyTimes.length; index++) {
addfruit = prompt("enter fruits name");
if (addfruit == "no") {
break;
}
fruitList.push(addfruit);
}
for (myShop of fruitList) {
output.innerHTML += myShop + "<br/>";
}
내 문제는 내가 5 번 프롬프트를 원할 때 1 프롬프트 만 얻을 수 있다는 것입니다.
어떤 도움을 주셔서 감사합니다.
당신은 그것을 사용할 수 있습니다.
let output = document.getElementById("output");
let addfruit;
let fruitList = [];
let howManyTimes = prompt("how many fruit to want to add?");
for (let index = 0; index < howManyTimes; index++) {
addfruit = prompt("enter fruits name");
if (addfruit == "no") {
break;
}
fruitList.push(addfruit);
}
for (myShop of fruitList) {
output.innerHTML += myShop + "<br/>";
}
당신은 이것을 실행할 것입니다
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다