Background
I'm trying to format some strings using plain JavaScript. It will be copy-pasted to a single cell in Google Sheet with a line break (alt + enter) in between. For example,
Code
let result = 'info1'
result += ', ' // replace with a line break
result += 'info2'
CopyToClipboard(result)
Problem
My closest attempt was using Google Sheet equation and char(10)
let result = '="info1"&char(10)&"info2"'
But since this solution changes the actual data, it's difficult to edit and reuse from the end-user perspective. I thought there must be a simpler way like /t and /n.
My not so successful tries include:
String.fromCharCode(10)
/r //r /n //n /t //t
Any advice would be appreciated!
Use backslash \ but not slash /
\n
var result;
result = 'info1'
result += '\n'
result += 'info2'
/* OR */
result = 'info1\ninfo2'
Alternative: Template literals
let result = `info1
info2`;