We're back with another week of challenges!
Today, let's get a little creative and develop a ranking system where we can sort points and calculat...
For further actions, you may consider blocking this person and/or reporting abuse
JavaScript
Live demo on Codepen.
This could be considerably reduced by using ternary operators.
Hi alvaro. Could u please explain what u did in this program by putting comments in ur codepen link. Im trying to understand😊
I updated the Codepen with comments. Let me know if more details are needed.
Thanku alvaro😊
My solution in clumsy Haskell:
Python
There's probably a better way which requires only one iteration?
i want to contribute my idea with your code. i hope u enjoy with that. Maybe it's shoter
players.sort((a, b) => {
return (a.points == b.points ? a.name > b.name : a.points < b.points) || -1;
}).map((e,i)=>({...e,position:(i+1)}))
Going functional in Perl:
Just a short one in Javascript
Edit: somehow I hadn't noticed the
position
bit 😳, so I've added that as a map call.Here it goes!
And the result:
Shouldn't John's position in the example be 3?