外层括号是i<a.length-1
内层括号是j<a.length-i-1
<script>
var a=[1,2,3,4,5];
for (let i = 0; i < a.length-1; i++) {
for (let j = 0; j < a.length-1-i; j++) {
if (a[j]<a[j+1]) {
var t=0;
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
console.log(a);
</script>