阅读 6

优秀的代码

var ret = member
            .filter(function(m, index){
                m.index = index;
                return !choosed[getKey(m)];
            })
            .map(function(m){
                return Object.assign({
                  score: Math.random()
                }, m);
            })
            .sort(function(a, b){
                return a.score - b.score;
            })
            .slice(0, count)
            .map(function(m){
              choosed[getKey(m)] = 1;
              list[m.index].style.color = color;
              return m.name + '<br/>' + m.no; 
            });
results = results.sort((x, y) => { return x.length - y.length;})
复制代码