Hey I've been trying to return the 2 smallest numbers from an array, regardless of the index. Can you please help me out?
Array#slice
var arr = [5, 4, 7, 2, 10, 1], res = arr.sort((a,b) => a - b).slice(0, 2); console.log(res);
1.4m articles
1.4m replys
5 comments
57.0k users