stringzy
Version:
A versatile string manipulation library providing a range of text utilities for JavaScript and Node.js applications.
14 lines (13 loc) • 399 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeDuplicates = removeDuplicates;
function removeDuplicates(text) {
if (typeof text !== "string") {
throw new Error("Input must be a string");
}
const wordSet = new Set();
text.split(" ").forEach((word) => {
wordSet.add(word);
});
return Array.from(wordSet).join(" ");
}