I have a map that I'm converting a specific string format using:
let content = "";
let myMap = new Map().set('a', 1).set('b', 2).set('c', 3);
myMap.forEach((value: string, key: number) => {
content += `${key}: ${value}, `;
});
However this will leave a comma at the end.
Is there some other way? e.g. to be able to use join?
Thanks,
[...myMap].map(([k, v]) => `${k}: ${v}`).join(", ");works.