Exercise 14: Remove Duplicate Characters
Problem Statement
Function `removeDuplicates(str)` banao jo string se duplicate characters remove kare.
Example: removeDuplicates("hello") => "helo"
Sample Output:
removeDuplicates("hello") => "helo"
removeDuplicates("aabbcc") => "abc"Solution
const removeDuplicates = (str) => [...new Set(String(str ?? ""))].join("");Explanation
Overall Goal:
- String se duplicate characters remove karna.
Real world:
- Data cleaning: unique characters.
- String processing: deduplication.