これが私のコードです。ユーザーがwindow.confirmボックスから「キャンセル」を選択したときに、このループを停止する方法がわかりません
私は本当にさびれていて、プログラミングを深く掘り下げたことはありません笑-私はC ++に慣れているので、window.confirm以外に呼び出すためのより良い関数があるかどうかはわかりません。
コード:
alert( "1 = 10, 2 = 20, 3 = 30, 4 = 40, 5 = 50" );
var myArray = [0, 10, 20, 30, 40, 50];
var askAgain = true;
var pickOne;
var pickTwo;
var answer;
var numOne;
var numTwo;
while (askAgain = true){
numOne = prompt( "Select a number by entering the associated slot #:");
numTwo = prompt( "Select a number to be added to the first number by
entering the associated slot #:" );
pickOne = myArray[numOne];
pickTwo = myArray[numTwo];
pickOne.Number;
pickTwo.Number;
answer = pickOne + pickTwo;
alert("You picked " + pickOne + " and " + pickTwo + ", combined they equal: "
+ answer);
window.confirm( "Would you like to go again?" );
if (confirm == true){
askAgain = true;
} else {
askAgain = false;
}
}
前もって感謝します!