JSFiddle - React, Tailwind, and code Playground
JavaScript
var users = [
{
name:"小明",
score:60
},
{
name:"小華",
score:90
},
{
name:"小乖",
score:99
},
];
var current_index = 0;
for(var i =1 ; i <users.length;++i){
if(users[i].score > users[current_index].score){
current_index = i;
}
}
alert("最高分為:" + users[current_index].name + ",分數為 "
+ users[current_index].score );