function bubsort(arr) {
    for (let i = 0; i < arr.length; i++) {
        for (let j = 0; j < arr.length-1-i; j++) {
            if (arr[j] > arr[j+1]) {
                [arr[j], arr[j+1]] = [arr[j+1], arr[j]]
            }
        }
    }
}

arr = [4,2,5,3,1]
console.log(arr)
bubsort(arr)
console.log(arr)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: