In Qualtrics, using JavaScript with embedded data and survey responses

Qualtrics allows JavaScript in the survey questions.  However, when reading and writing embedded data based on survey responses using JavaScript, the syntax is a little weird.  This post walks through an example of using JavaScript to …
(1) read embedded data (strings and numbers)
(2) accept survey responses, and
(3) change the embedded data based on the survey responses (i.e., conditional processing).

The process is straightforward.  The only weirdness is the syntax.  So, the simple example below shows the technique at work.  First, the survey flow shows the embedded data initialization.  Next, the survey questions are shown.  Next, the JavaScript (part of Q3) is shown as a screen-grab and as a text file.  Finally, the survey output is shown (across three screens).

Survey flow

Survey questions

JavaScript (as screen capture)

JavaScript (as text)

Survey output, page 1
Survey output, page 2
Survey output, page 3