Write a function removeDuplicates(values) that returns a new array without duplicates: every value stays once.
values is an array of numbers and strings. One array can hold both.[3, 1, 3, 2, 1] gives [3, 1, 2]. Do not sort the result.===): 1 and '1' are different, 'a' and 'A' are different.[].The interviewer asked you not to use Map or Set. The tests check only the result; keep to the rule yourself. The array method includes can tell you if a value is already in the result.
removeDuplicates([3, 1, 3, 2, 1])Returns [ 3, 1, 2 ]
removeDuplicates(['b', 'a', 'b'])Returns [ 'b', 'a' ]
removeDuplicates([1, '1', 1])Returns [ 1, '1' ]
Asked at GlobalLogic · Source
removeDuplicates([ 3, 1, 3, 2, 1 ])[ 3, 1, 2 ]removeDuplicates([ 'b', 'a', 'b' ])[ 'b', 'a' ]removeDuplicates([ 4, 5, 6 ])[ 4, 5, 6 ]Hidden tests run on Submit.