Junior — Senior
Forming a string representation of array number ranges
livecode
Task condition
You need to write a function range that takes an array of integers and returns a string listing all continuous ranges of values. Ranges are combined in the form start-end, single numbers are displayed without a dash, and separate ranges are divided by commas.
range([1, 4, 5, 2, 3, 9, 8, 11, 0]) // '0-5,8-9,11'
range([1, 4, 3, 2]) // '1-4'
function range(numbers) {
}