<!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 type="text/javascript"> const _rank = array => { // 补全代码 array.forEach(item => { //为原对象添加sum属性 item['sum'] = item.chinese + item.math + item.english; }) array.sort((a, b) => { return b.sum - a.sum }) return array; } _rank([ { name: 'xiao', chinese: 98, math: 100, english: 30 }, { name: 'hon', chinese: 99, math: 90, english: 50 }, { name: 'ming', chinese: 70, math: 90, english: 90 } ]) </script> </body> </html>