Files
swingmusic-extended/src/utils/usePutCommas.ts
T
2022-08-04 18:43:12 +03:00

19 lines
426 B
TypeScript

/**
* Turns a list of artists into a string of artists separated by commas.
* @param artists artists array to put commas in
* @returns a string with commas in between each artist
*/
export default (artists: string[]) => {
let result = [];
artists.forEach((i, index, artists) => {
if (index !== artists.length - 1) {
result.push(i + ", ");
} else {
result.push(i);
}
});
return result;
};