CodePudding user response:
//give it a try, hand tapping, no test, should be the correct
The function getMax (list, num) {
Var result=[];
List. The sort (). The reverse () foreach ((p)=& gt; {
If (result. The lenth & lt; Num) {
If (result. IndexOf (p)!=1) {
Result. Push (p);
}
}
})
return result;
}
CodePudding user response:
The habitual knocked at the wrong place,,,, correct the following
//give it a try, hand tapping, no test, should be the correct
The function getMax (list, num) {
Var result=[];
List. The sort (). The reverse () foreach ((p)=& gt; {
If (result. The lenth & lt; Num) {
If (result. IndexOf (p)==1) {
Result. Push (p);
}
}
})
return result;
}
CodePudding user response:

//ok, it is wrong, this is a test
The function getMax (list, num) {
Var result=[];
Var arr=list. Sort (). The reverse ();
For (var I=0; I & lt; Arr. Length; I++) {
If (result. Length & lt; Num) {
If (result. IndexOf (arr) [I]==1) {
Result. Push (arr [I]);
}
}
}
return result;
}
CodePudding user response:
Var map=new map ();
The map. The set (" A ", 86);
The map. The set (" B ", 112);
The map. The set (" C ", 6);
The map. The set (" D ", 99);
The map. The set (" E ", 44).
The map. The set (" F ", 135);
Var arr=[... the map values ()]. Sort ((a, b)=& gt; B - a). Slice (0, 3);
The console. The log (arr);
CodePudding user response:
Need to go to a weight in the Set objectVar arr=[... new Set (map) values ())), sort ((a, b)=& gt; B - a). Slice (0, 3);