GitHub 6248★

Trim some character

JavaScript version

const trim = (str, char) => str.split(char).filter(Boolean).join();

TypeScript version

const trim = (str: string, char: string): string => str.split(char).filter(Boolean).join();

Examples

trim('/hello world//', '/'); // hello world
trim('"hello world"', '"'); // hello world
trim(' hello world ', ' '); // hello world
Follow me on and to get more useful contents.