1

I am trying to do a simple evaluation for an instructions type block in jsypscyh. Whenever, I input a variable into my return_essay function, my instructions page won't load correctly (shown below). However, if I insert a string or integer directly then the page loads correctly.

How can I get the instructions to evaluate my variables?

function return_essay(input) {
      return ['<p>You wrote: <br>' + input + '</p>']
}

var show_writing = {
  on_load: function() {
    var zzz = 2;
  },
  type: 'instructions',
  pages: return_essay(zzz),
  show_clickable_nav: false
}
John-Henry
  • 1,556
  • 8
  • 20

1 Answers1

0

The problem was that the page was loading with a static reference. Solution is to update the page directly on load:

function return_essay(input) {
      return ['<p>You wrote: <br>' + input + '</p>']
}

var show_writing = {
  on_load: function(trial) {
    var zzz = 2;
    trial.pages = return_essay(zzz);
  },
  type: 'instructions',
  pages: return_essay(zzz),
  show_clickable_nav: false
}
John-Henry
  • 1,556
  • 8
  • 20