[SOLVED] Implementing bubble sort giving unexpected error

i’ve implemented the bubble sort but when running the test i get the following error:

bubbleSort should not use the built-in .sort()

Here’s the code

function bubbleSort(array) {
var sorted = false;
while(!sorted) {
  let swap=0;
  for( let i=0; i<array.length-1; i++) {
    if(array[i] > array[i+1]) {
      let aux = array[i+1];
      array[i+1] = array[i];
      array[i] = aux;
  sorted = swap === 0;
return array;

bubbleSort([1, 4, 2, 8, 345, 123, 43, 32, 5643, 63, 123, 43, 2, 55, 1, 234, 92]);

** browser information:**

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36.

Challenge: Implement Bubble Sort

Link to the challenge:

to check if you are actually not using the sort method, the tests will check if you have used “sort” anywhere in the code, this will cause the issue that also any variable with a similar name, or comment, will cause the test to fail
Try changing your variable names

Hello and welcome back to the FCC community~!

It looks like your sorted variable is throwing the tests off. When I changed it to Sorted, the tests passed. :slight_smile:

The challenge is searching for the word sort. Change the variable sorted to something else and your code will work fine.