Ivankooo1

Inventory

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