使用JavaScript实现冒泡排序
let stuScore = ['2', '1', '3', '4', '5'];
for (i = 0; i < stuScore.length; i++) {
for (j = 0; j < stuScore.length - i - 1; j++) {
if (stuScore[j] < stuScore[j + 1]) {
let temp = stuScore[j];
stuScore[j] = stuScore[j + 1];
stuScore[j + 1] = temp;
}
}
}
stuScore.forEach((element) => {
console.log(element);
});