Template literal strings being stripped out of javascript | XM Community
Skip to main content

I have the following javascript code being used in the Javascript Question API:
---
Qualtrics.SurveyEngine.addOnReady(function()
{
const a = 44;
const b = -82;
const msgText = ` style="font-size: ${Math.abs(a + b)}px;">
   a
   ${a > b ? '>' : '<' }
    b
 

`;
jQuery("#targetelement").html(msgText);
});
---
(this code is part of a larger project which makes extensive use of ES6's template literals feature).
This code is expected to display the following string in a 38 pixel font:
a > b
however, when I preview the page in Qualtrics, I get back "a b" (without the angle bracket). It's almost as if Qualtrics is erasing the interpolated expressions of my template literal (the bits in ${}).
Does Qualtrics not support ES6 syntax in its editor?

Template literals are supported, but expression interpolation is not.
The

${}
placeholder is used by Qualtrics for piping text, so it doesn't work.


Leave a Reply