How to assign a multiline string to a variable in JavaScript?
Hello everyone! I just started learning JavaScript and encountered a problem that seems very simple to me, but I can't find an elegant solution.\n\nI need to store a long text that spans multiple lines in a variable. For example, I want to write a multiline greeting or an HTML template. When I try to do it the usual way using single or double quotes, it breaks.\n\nHere's how I'm trying to do it:\n\n```javascript\nvar message = 'Hello, world!\nThis is the second line.\nAnd this is the third line.';\n```\n\nBut JavaScript throws an error because a string cannot be broken with a line break inside single quotes. I tried using a backslash `\\` at the end of each line, but it looks very ugly and inconvenient, especially if there are many lines.\n\nI've