File size: 363 Bytes
9bcdb59
 
 
 
 
 
1
2
3
4
5
6
// clean a list of words (which may be null, undefined or empty)
// into one clean string of separator-divided (by default comma-separated) words
// the words will be trimmed, and empty elements will be removed
export function joinWords(inputs: any[] = [], separator = ", "): string {
  return inputs.map(x => `${x || ""}`.trim()).filter(x => x).join(separator)
}