Map Inside Template Literals Causes Commas

Published: Aug 29 ยท 1 min read

Template literals use the Template literals use the toString() method which by default joins the returned array by method which by default joins the returned array by map with a with a ,. . To avoid this To avoid this "problem" "problem" you can use you can use join('')[1]

js
const arr = [1, 2, 3]
const str = `Numbers: ${arr.map(x => x + 1).join('')}`

  1. Stackoverflow Stackoverflow โ†ฉ๏ธŽ