Count answered questions

Simple way to add a number value to count the number of questions answered.
This will then place the count answer into a variable.
Here is a simple script.
var qanswer = f(‘qnr_countquestions‘);
var i = 0 ;
if(f(‘qnr_questionsone‘).toBoolean()){
  i = i+1;
qanswer.set(i);
      }
if(f(‘qnr_questiontwo‘).toBoolean()){
  i = i+1;
qanswer.set(i);
      }
Just add the same IF statement to add more questions to count.