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

Source: Internet
Author: User

<! 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.