https://www.codewars.com/kata/5174a4c0f2769dd8b1000003
Codewars - Achieve mastery through coding practice and developer mentorship
A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!
www.codewars.com
DESCRIPTION:
Finish the solution so that it sorts the passed in array of numbers. If the function passes in an empty array or null/nil value then it should return an empty array.
For example:
solution([1, 2, 10, 50, 5]); // should return [1,2,5,10,50]
solution(null); // should return []
코드
function solution(nums){
return (nums || []).sort((a, b) => a - b);
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Directions Reduction (5 kyu) / JavaScript (0) | 2023.03.30 |
---|---|
[Codewars] Surface Area and Volume of a Box (8 kyu) / JavaScript (0) | 2023.03.29 |
[Codewars] All Star Code Challenge #18 (8 kyu) / JavaScript (0) | 2023.03.27 |
[Codewars] Enumerable Magic - Does My List Include This? (8 kyu) / JavaScript (0) | 2023.03.26 |
[Codewars] Find the capitals (7 kyu) / JavaScript (0) | 2023.03.25 |
댓글