Looking for best solution of HackerRank project. #37044
-
const names = ["Harry:-5", "Robbie:3", "Alexandra:3", "Michelle:4", "Malcolm", "Susan:2", "Ellen:2", "Robbie:2", "Philip:2", "Max:1", "Marlin:-4", "Michelle:-3", "Richard:5", "Malcolm", "Ellen:3", "Philip:-2", "Susan:-7", "Harry:-1", "Robbie:4", "Alexandra:-1", "Malcolm", "Richard:2", "Marilyn:-2", "Michelle:-2", "Susan:2", "Philip:1", "Richard:5","Marilyn:3", "Harry:3"]; const str = []; const res = str.reduce((pre, cur, ind) => { for (x in res) { const ans = Object.keys(res).sort().reduce((pre, cur)=> { const objTostr = (obj) => Object.entries(obj).map(([key, value]) => console.log(objTostr(ans)); Above is my solution, Can anybody help me? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi @MacarioLee, I wanted to jump in and mention that if you're looking for help for this specific topic, you might want to try asking for help somewhere that focuses on the specific topic. It's definitely possible that another GitHub user might have run into this same issue and can help, but the GitHub Community on Discussions focuses primarily on topics related to GitHub itself or collaboration on project development and ideas. We want to make sure you’re getting the best support you can, but this space may not be the right place for this particular topic. Best of luck! |
Beta Was this translation helpful? Give feedback.
-
That is my answer. I hope it would be help to you. const givenArr = ["Harry:-2", "Robbie:3", "Alexandra:3", "Michelle:4", "Malcom:2", "Susan:2", "Ellen:2", "Robbie:2", "Philip:2", "Max:1", "Marilin:-4", "Michelle:-3", "Richard:5", "Malcom:3", "Ellen:3", "Philip:-2", "Susan:-7", "Harry:-1", "Robbie:4", "Alexandra:-1", "Malcom:3", "Richard:2", "Marilyn:-2", "Michelle:-2", "Susan:2", "Philip:1", "Richard:5","Marilyn:3", "Harry:3"]; let uniqueUsers = [] givenArr.sort().map(ele => { |
Beta Was this translation helpful? Give feedback.
That is my answer. I hope it would be help to you.
const givenArr = ["Harry:-2", "Robbie:3", "Alexandra:3", "Michelle:4", "Malcom:2", "Susan:2", "Ellen:2", "Robbie:2", "Philip:2", "Max:1", "Marilin:-4", "Michelle:-3", "Richard:5", "Malcom:3", "Ellen:3", "Philip:-2", "Susan:-7", "Harry:-1", "Robbie:4", "Alexandra:-1", "Malcom:3", "Richard:2", "Marilyn:-2", "Michelle:-2", "Susan:2", "Philip:1", "Richard:5","Marilyn:3", "Harry:3"];
let uniqueUsers = []
givenArr.sort().map(ele => {
const key = ele.split(":")[0];
const value = Number(ele.split(":")[1]);
let searchedUsers = uniqueUsers.filter(user => {
return String(Object.keys(user)) === key
}) ;
if(searchedUsers.length > 0) {
searchedUsers[0]…