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
}
4

1 回答 1

0

问题是页面正在加载静态引用。解决方案是在加载时直接更新页面:

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
}
于 2020-08-26T18:13:37.383 回答