I'm new to Qualtrics/JavaScript... would appreciate help on
Var block1= [parseInt("${q://QID664/SelectedAnswerRecode/1}"), parseInt("${q://QID664/SelectedAnswerRecode/2}"), parseInt("${q://QID664/SelectedAnswerRecode/3}"), parseInt("${q://QID664/SelectedAnswerRecode/4}"), parseInt("${q://QID664/SelectedAnswerRecode/5}"), parseInt("${q://QID664/SelectedAnswerRecode/6}"), parseInt("${q://QID664/SelectedAnswerRecode/7}"), parseInt("${q://QID664/SelectedAnswerRecode/8}"), parseInt("${q://QID664/SelectedAnswerRecode/9}"), parseInt("${q://QID664/SelectedAnswerRecode/10}")];
`for(i=0;i<block1.length;i++) {
`diff_array[i]= block1[i+1]- block1[i]}`
Next, I want to do the following:
-find ones in array
num_switch_block1= number of ones in difference array)
-create lambda variable-
lambda_multiplier= [.7, .9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.1, 2.3]
Is there a more elegant way to increment that array? Should I set this as embedded data? -multiply difference array by lambda_multiplier
`var mult = multiply(diff_array,lambda_multiplier);`
-then reduce this array to only the non-zero values
mult.filter (Boolean)
Am I using the right functions/doing this right?
Not sure what you will do with the array mult, but here is code to create it (untested):