I'm trying to print the error message if the minimum value > maximum value for both horizontal and vertical directions for my multiplication table.
For some reason, my code only prints the error message if the Row values have to be swapped, it doesn't print the message for Column values. Also, I need a case if they both have to be swapped, but when I add this condition nothing works(I left it commented out).
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.textContentinstead of replacing its value. Start witherror.textContent = '';, then doerror.textContent += 'your error';whenever you need to show a message. Then you can get rid of theelseat the bottom.