Tell us what’s happening:
what is wrong?
Your code so far
function bubbleSort(array) {
// change code below this line
for(let i=0;i<array.length; i++){
for(let j=i+1;j<array.length; i++){
if(array[i]>array[j]){
let temp = array[j];
array[j]=array[i];
array[i]= temp;
}
}
}
// change code above this line
return array;
}
// test array:
// [1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/coding-interview-prep/algorithms/implement-bubble-sort