You are replacing error.textContent every time you hit one of your if conditions, meaning only error message can be set at a time. Also, your else is deleting the message if minRow > maxRow is false, ignoring the minCol > maxCol condition.

Try setting error.textContent = ''; at the beginning and then appending to the error message.

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";
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top