掛け算の九九の水平方向と垂直方向の両方で最小値>最大値の場合、エラーメッセージを出力しようとしています。
何らかの理由で、私のコードは、行の値を交換する必要がある場合にのみエラーメッセージを出力し、列の値のメッセージは出力しません。また、両方を交換する必要がある場合はケースが必要ですが、この条件を追加しても何も機能しません(コメントアウトしたままにしました)。
script.js:
if(minCol>maxCol)
{
let temp = maxCol;
maxCol = minCol;
minCol = temp;
error.textContent = "Minimum Column Value has been swapped with Maximum Column Value.";
error.style.color = "red";
}
if(minRow>maxRow)
{
let temp = maxRow;
maxRow = minRow;
minRow = temp;
error.textContent = "Minimum Row Value has been swapped with Maximum Row Value.";
error.style.color = "red";
}
/*
if(minCol>maxCol && minRow>maxRow)
{
error.textContent = "Minimum Column and Row Value has been swapped with Maximum Column and Row Value.";
error.style.color = "red";
}
*/
else
{
error.textContent = "";
}
あなたはされている交換 error.textContent
あなたの1ヒット毎回if
時に設定することができる唯一のエラーメッセージを意味し、条件を。また、falseのelse
場合minRow > maxRow
、minCol > maxCol
条件を無視してメッセージを削除しています。
error.textContent = '';
最初に設定してから、エラーメッセージに追加してみてください。
error.textContent = "";
if(minCol>maxCol)
{
let temp = maxCol;
maxCol = minCol;
minCol = temp;
error.textContent += "Minimum Column Value has been swapped with Maximum Column Value.";
error.style.color = "red";
}
if(minRow>maxRow)
{
let temp = maxRow;
maxRow = minRow;
minRow = temp;
error.textContent += "Minimum Row Value has been swapped with Maximum Row Value.";
error.style.color = "red";
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加