Skip to content

Commit 8e9b8a6

Browse files
problem 54 completed in complex way
1 parent 1205375 commit 8e9b8a6

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

problem54/problem54.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,38 @@ Loop
1212
Function
1313
Array
1414
15-
*/
15+
*/
16+
17+
18+
const highestRunScorer = players => {
19+
const allPlayersRun = [];
20+
for( let i = 0; i < players.length; i++){
21+
22+
const player = players[i];
23+
const playerRun = player[1];
24+
allPlayersRun.push(playerRun);
25+
}
26+
27+
const topRuns = Math.max(...allPlayersRun);
28+
29+
for( let x = 0; x < players.length; x++){
30+
if(players[x][1] == topRuns){
31+
32+
return players[x][0];
33+
}
34+
}
35+
}
36+
37+
38+
const playersInfo = [
39+
["Asraful", 95],
40+
["Sakib", 19],
41+
["Musfique", 35],
42+
["Mahmudullah", 45],
43+
["Mashrafee", 13]
44+
];
45+
46+
const result = highestRunScorer(playersInfo);
47+
48+
console.log(`The highest run scorer is ${result}`);
49+

0 commit comments

Comments
 (0)