I am using javascript to display in a web page the number list at the end of each iteration in the Bubble Sorting method. The function seems like failed to sort, and I couldn't figure it why.

I am assuming the mistake I made is around the loop area.

```
<!DOCTYPE html>
<html>
<head>
  <title>Bubble Sort</title>
<script type="text/javascript">

var array = new Array();
function pushArray(){
array.push((document.getElementById("elem").value));
    document.getElementById("elem").value = '';

}

function isNumber(evt) {
    evt = (evt) ? evt : window.event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        return false;
    }
    return true;
}

var count = 1
function myFunction() {

    document.write("Array you entered was "+ array);
    var arrayLength = array.length;
    var i;
    var j;
    var k;
    for(i=0;i<arrayLength;i++)
    {
        for(j=i+1;j<arrayLength;j++)
        {
          if(array[i]<array[j])
          {
                    k=array[i];
                    array[i]=array[j];
                    array[j]=k;

          }
    document.write("<br/><br/>"+ count+"th iteration produced : " + array);
    count = count + 1;

        }

    }
    document.write("<br/><br/>After bubble sort in desending order " + array);
}

</script>
</head>
<body data-gr-c-s-loaded="true">

Enter the element here: <input type="text" id="elem" onkeypress="return isNumber(event)">
<br>
<button onclick="pushArray()">Add this element</button>

<p>Click the button to sort the array.</p>

<button onclick="myFunction()">Try it</button>

</body></html>

```