I have a 2D array:
[["user1", 20], ["user2", 30], ["user3", 10]]
The first element of a subarray is the username, and the second one its score.
I need to return the username with the maximum score. For example, here it would return "user2"
.
Either one user has a higher score, or they all have the same score (in which case it should return "all"
).
I know how to do this with a bunch of iterations and many lines of code, but I'm trying to find the "best practice way".
What would you advise ?