let ostatki = [170,170,170,170,170,890,130,130,130,260]; ostatki = ostatki.map(el=> el+'мм - '+ostatki.filter(x=> x==el).length +'штук').filter((e, i, s)=>s.indexOf(e) === i).sort((a,b)=> parseInt(a)- parseInt(b)); console.log(ostatki);