<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<script type= "Text/javascript" >
The results of a group of students, the output of the total score is who and scores, the output of the first name of the language who and scores
var score = [
{
Name: ' Xiaoming ',
chinese:128,
math:127,
english:145
},
{
Name: ' Cauliflower ',
chinese:139,
math:140,
english:141
},
{
Name: ' Little Fang ',
chinese:148,
MATH:120,
english:115
},
{
Name: ' Xiao Li ',
chinese:122,
math:148,
english:115
}
]
Sort by total
Score.sort (function (A, b) {
if (A.chinese + A.math + a.english > B.chinese + b.math + b.english)
{
return-1;
} else
{
return 1;
}
})
Console.log (' Total scores first ' is ' + score[0].name + ' language ' + Score[0].chinese + ' math ' + score[0].math + ' English ' + score[0].english)
Score.sort (function (A, b) {
if (A.chinese > B.chinese)
{
return-1;
} else
{
return 1;
}
})
Console.log (' The first name of the language is ' + score[0].name + ' score ' + Score[0].chinese)
</script>
<body>
</body>
↓
Using a two-dimensional array to save a group of students ' scores, the output of the total number of WHO and scores, the output of the first name of the language and the results