Liliana797979

inventory - fundamentals

Jul 4th, 2021
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arr){
  2.  
  3.     let heros = []
  4.  
  5.     arr.map(x => x.split(' / '))
  6.  
  7.     .map(x => heros.push({name: x[0], level: +x[1], items: x[2].split(', ').sort((a, b) => a.localeCompare(b)).join(', ')}))
  8.  
  9.  
  10.  
  11.     heros.sort((a, b) => a.level - b.level)
  12.  
  13.     .map(x => console.log(`Hero: ${x.name}\nlevel => ${x.level}\nitems => ${x.items}`))
  14.  
  15. }
Advertisement
Add Comment
Please, Sign In to add comment