I want to take a string, such as
const code = `
<code>
This is some code
</code>
`
and convert it automatically to a one line string, using \n for breaks and \t for tabs.
After conversion it should look like:
const code = "\n\tThis is some code\n"
How can this be done in JavaScript? I saw posts solving how to add line breaks, but found nothing for tab support.