Variable in API request is not detected

Hello, I have a problem with the API call. If I insert a variable ‘XYZ’ as value for the prompt, then the response to the request is wrong.
If instead of the variable ‘XYZ’ I insert its value as a string, for example "Write 3 sentences on the topic " then the result is as expected.
So it seems that the API request does not recognize the first variable ‘XYZ’. What could be the reason for this?

var XYZ = "Write 3 sentences on the topic "

Example that doesnt work

// configure the API request to OpenAI
const payload = {
"model": "text-davinci-002",
"prompt": XYZ + val + "\n",
...
}

Example that works fine:

// configure the API request to OpenAI
const payload = {
"model": "text-davinci-002",
"prompt": "Write 3 sentences on the topic " + val + "\n",
...
}