gistlib
index.tsconst removeDuplicates = (arr: string[]): string[] => { return arr.filter((item, index) => arr.indexOf(item) === index); }; // Example const arr = ['apple', 'banana', 'orange', 'apple', 'banana']; const uniqueArr = removeDuplicates(arr); console.log(uniqueArr); // Output: ['apple', 'banana', 'orange'] 308 chars9 lines
const removeDuplicates = (arr: string[]): string[] => { return arr.filter((item, index) => arr.indexOf(item) === index); }; // Example const arr = ['apple', 'banana', 'orange', 'apple', 'banana']; const uniqueArr = removeDuplicates(arr); console.log(uniqueArr); // Output: ['apple', 'banana', 'orange']
gistlibby LogSnag