const bubbleSort = (arr) => { for (let i = 0; i < arr.length - 1; i++) { for (let j = 0; j < arr.length - 1; j++) { // compare arr[j] to arr[j+1] // swap places if needed } } return arr; };