Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 622 Bytes

sort-numbers.md

File metadata and controls

24 lines (17 loc) · 622 Bytes

Sort Numbers 7 Kyu

LINK TO THE KATA - FUNDAMENTALS

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 []

Solution

const solution = nums => (nums === null ? [] : nums.sort((a, b) => a - b))