这个作业属于哪个课程 | https://edu.cnblogs.com/campus/sdscfz/SF4 |
---|---|
这个作业要求在哪里 | https://edu.cnblogs.com/campus/sdscfz/SF4/homework/12964 |
这个作业的目标 | 第8次作业-数组排序(冒泡排序) |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="./51.js">
</script>
</body>
</html>
var arr=[98、31、5、27、2、78];
for(let i = 0;i<arr.length;i++){
for(let y=i;y>0;y--){
if(arr[y]<arr[y-1]){
[arr[y-1],arr[y]]=[arr[y],arr[y-1]]
}
}
}
document.write(arr);