Sobes.tech
Junior — Senior

Getting a sequence without adjacent duplicates

livecode

Task condition

It is necessary to implement a function that takes an arbitrary set of elements (a string or an array) and returns a new array in which consecutive identical values are removed, and the order of the remaining elements is preserved.

// Examples:
// extractUnique('AAAABBBCCDAABBB') => ['A', 'B', 'C', 'D', 'A', 'B']
// extractUnique('ABBCcAD') => ['A', 'B', 'C', 'c', 'A', 'D']
// extractUnique([1,2,2,3,3]) => [1,2,3]

function extractUnique(seq) {}