Hi community,
I'm very new to javascript and Qualtrics custom coding so my issue may be a simple one but it doesn't seem to have a solution presented anywhere. In my survey I implement some js code to randomize the use of a term across questions. For example:
// randomly select term
var term_array = ["big", "scary", "inviting", "attractive", "confusing", "opaque"];
var rnd = Math.floor(Math.random()*6);
var term = term_array[rnd];
var out = `Does the above image look ${term} to you?`;
The string in the variable "
out" is then outputted to an html script which displays the question.
The problem is that everything in the outputted string except the placeholder is being displayed when I preview the question.
So to illustrate, if
term= "scary", instead of displaying "Does the above image look scary to you?" the output displayed is "Does the above image look to you?"
This is unexpected because when I check the code in other javascript editors (such as https://js.do), the correct output is always displayed. Is there any Qualtrics-specific reason why this may be occurring? And is there another way to go about interpolating strings which may avoid this problem altogether? Thank you!
Best answer by SurajK
View original