Jump to content

Jenith

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by Jenith

  1. Hi, many thanks for your assistance. 

    I have tried to create a loop but I am having a similar problem - all six sentences are presented as one. 

        example of code I have tried:

    for (i = 0; i < feedback.array1.length; i++){

     msg_feedback1 += feedback_array1

    I've had a look at setTimout() and I'm not sure a time sensitivity option will work either. In the game, the participant will press a button and then be shown feedback. They press the button again and will be shown a different feedback sentence. I can get this to work if the feedback is random - as per the code stated above. But this information is not stored. 

    Can anyone recommend anything else I might try??

  2. Hi, I'm a Psychology student and newbie to javascript. I am trying to create a behavioural task on qualtrics using javascript. 

    The game works and I am able to provide the participant with feedback at the end of each round (there are 10 atm). What I would like to know is whether there is a way for the following six sentences to be presented one at a time in a consecutive order? 

    I can get the task to present one of the six at random, however, when I remove Math.random from the code, all six sentences are displayed as one chunk. 

    var feedback_array1= [
                            "<p>Congratulations you won the game.  </ p> <p>The other player picked A</p>",
                             "<p>Congratulations you won the game.  </ p> <p>The other player picked B</p>",
                            "<p>Congratulations you won the game.  </ p> <p>The other player picked C</p>",
                            "<p>You lost! </p><p>The other player picked A</p>",
                            "<p>You lost! </p><p>The other player picked B</p>",
                             "<p>You lost! </p><p>The other player picked C</p>", ];

     

        var msg_feedback1 = function(){
                return feedback_array1 [Math.floor(Math.random()*feedback_array1.length)] ; 

    };

    An alternative method would be to save the order of the randomized feedback, through I have had much luck devising that either! 

    Any help would be greatly appreciated. Many thanks in advance! 

×
×
  • Create New...