Skip to content

Commit e9ad4d2

Browse files
committed
code refactor
1 parent fa445fa commit e9ad4d2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
export default function cleanSet(set, startString) {
2-
const filteredSet = Array.from(set).filter((val) => val.startsWith(startString));
3-
const cleanedValues = filteredSet.map((val) => val.substring(startString.length));
4-
return cleanedValues.join('-');
2+
if (!startString || !startString.length || typeof startString !== 'string') return '';
3+
4+
let finalString = '';
5+
set.forEach((element) => {
6+
if (element && element.startsWith(startString)) finalString += `${element.slice(startString.length)}-`;
7+
});
8+
9+
return finalString.slice(0, finalString.length - 1);
510
}

0 commit comments

Comments
 (0)