Tell us what’s happening:
I wrote this code. I don’t what’s wrong with this log. It is returning sorted array. Still the tests are not passing.
Your code so far
function bubbleSort(array) {
// Only change code below this line
n = array.length
for (let pass = n-1; pass >0; pass--) {
for (let j = 0;j<pass;j++)
{
if(array[j]>array[j+1])
{
temp = array[j];
array[j] = array[j+1];
array[j+1] = temp;
}
}
}
return array;
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Challenge Information:
Algorithms - Implement Bubble Sort