I have some HTML text in which I pass a value from a randomised vector.
Like so:
var source = jsPsych.randomization.sampleWithoutReplacement(["source1", "source2", "source3", "source4", "source5"]);
According to the <span style="background-color:' + colour[0] + ' "> ' + source[0] + '</span>, it will raise taxes for the average person by 20,000 Krona, it will result in lost jobs, and it will have no tangible positive impact on the economy until at least 2022.
This 'source' variable relates to the name of an organisation followed by its acronym. The acronym is then referred to later in the text and I would like to create a statement such that when the acronym is cited it matches the initial source cited. I tried creating another vector for the acronym using if/else if statements but haven't managed to get this to work.
Thus, according to the <span>'+ sourceAc +'</span>, there will be an unresolved deficit for many years to come
Is there a simple way to do this?
EDIT:
I've tried to do this using if / else if statements and also with a switch statement, but the inputted value is 'undefined'.
This is one approach I tried:
var sourceAc;
if (source === "Foundation for Economic Education (FEE)") { sourceAc = "FEE";}
else if (source === "Economic Policy Institute (EPI)") { sourceAc = "EPI";}
else if (source === "The Center of Economic and Policy Research (CEPR)") { sourceAc = "CEPR";}
else if (source === "Tax Research Foundation") { sourceAc = "Tax Research Foundation";}
else if (source === "Office of International Economic Affairs (OIEA)") { sourceAc = "OIEA";}
The resulting text should look something like this:
According to the report from the **source1**, the proposed tax increases will hurt businesses. ...
Thus, according to the **source1acronym**, there will be an unresolved deficit for many years to come.