# Stuck on initialising the experiment page

**URL:** https://discourse.psychopy.org/t/stuck-on-initialising-the-experiment-page/28232
**Category:** Online experiments
**Tags:** screen, online, pavlovia
**Created:** [March 27, 2022, 11:06am UTC](https://discourse.psychopy.org/t/stuck-on-initialising-the-experiment-page/28232 "2022-03-27T11:06:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![zfy1394496908](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zfy1394496908/32/33211_2.png) [@zfy1394496908](https://discourse.psychopy.org/u/zfy1394496908)
#### Post date: [March 27, 2022, 11:06am UTC](https://discourse.psychopy.org/t/stuck-on-initialising-the-experiment-page/28232/1 "2022-03-27T11:06:06Z")

</div>

URL of experiment: [dscrimination [PsychoPy]](https://run.pavlovia.org/Fengying/dscrimination/)  
[dscrimination.py](https://discourse.psychopy.org/uploads/short-url/pU9v3St3QlwMGvlbKDUSLucIDwY.py) (134.5 KB)

Description of the problem: when I add the following code component into my experiment, it couldn’t finish the initialisation online but it runs offline. The check page shows "Uncaught SyntaxError: unexpected token ‘var’ ".

Could anyone help me with it? I have checked all the relevant topics but still can’t solve this problem.

```auto
if choose_2.status == FINISHED:
    k = ""
    for key in choose_2.keys[:-1]:
        k = k + key
    if k == '1':
        opt1_2.color = 'green'
    elif k == '2':
        opt2_2.color = 'green'
    elif k == '3':
        opt3_2.color = 'green'
    elif k == '4':
        opt4_2.color = 'green'
    elif k == '5':
        opt5_2.color = 'green'
    elif k == '6':
        opt6_2.color = 'green'
    elif k == '7':
        opt7_2.color = 'green'
    elif k == '8':
        opt8_2.color = 'green'
    elif k == '9':
        opt9_2.color = 'green'
    elif k == '10':
        opt10_2.color = 'green'
    elif k == '11':
        opt11_2.color = 'green'
    elif k == '12':
        opt12_2.color = 'green'
    elif k == '13':
        opt13_2.color = 'green'
    elif k == '14':
        opt14_2.color = 'green'
    elif k == '15':
        opt15_2.color = 'green'
    elif k == '16':
        opt16_2.color = 'green'
    elif k == '17':
        opt17_2.color = 'green'
    elif k == '18':
        opt18_2.color = 'green'
    elif k == '19':
        opt19_2.color = 'green'
    elif k == '20':
        opt20_2.color = 'green'

```

[dscrimination.py](https://discourse.psychopy.org/uploads/short-url/pU9v3St3QlwMGvlbKDUSLucIDwY.py) (134.5 KB)

---

<div class="post-metadata">

### Author: ![zfy1394496908](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zfy1394496908/32/33211_2.png) [@zfy1394496908](https://discourse.psychopy.org/u/zfy1394496908)
#### Post date: [March 27, 2022, 11:14am UTC](https://discourse.psychopy.org/t/stuck-on-initialising-the-experiment-page/28232/2 "2022-03-27T11:14:02Z")

</div>

the first lines of the following two sets of code are where the error report points at. I am completely ignorant about codes, so bear with me, please. if you need more info about the experiment, please leave a comment. I’ll reply to you right away!

```auto
    if (choose_2.status === PsychoJS.Status.STARTED && Boolean(var _pj;
    function _pj_snippets(container) {
        function in_es6(left, right) {
            if (((right instanceof Array) || ((typeof right) === "string"))) {
                return (right.indexOf(left) > (- 1));
            } else {
                if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
                    return right.has(left);
                } else {
                    return (left in right);
                }
            }
        }
        container["in_es6"] = in_es6;
        return container;
    }
    _pj = {};
    _pj_snippets(_pj);
    _pj.in_es6("g", choose_2.keys))) {
      choose_2.status = PsychoJS.Status.FINISHED;
  }

```

```auto

    var _pj;
    function _pj_snippets(container) {
        function in_es6(left, right) {
            if (((right instanceof Array) || ((typeof right) === "string"))) {
                return (right.indexOf(left) > (- 1));
            } else {
                if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
                    return right.has(left);
                } else {
                    return (left in right);
                }
            }
        }
        container["in_es6"] = in_es6;
        return container;
    }

```

---

<div class="post-metadata">

### Author: ![wakecarter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/wakecarter/32/5753_2.png) [@wakecarter](https://discourse.psychopy.org/u/wakecarter)
#### Post date: [March 28, 2022, 10:25am UTC](https://discourse.psychopy.org/t/stuck-on-initialising-the-experiment-page/28232/3 "2022-03-28T10:25:47Z")

</div>

> [@zfy1394496908](#):
>
> Uncaught SyntaxError: unexpected token ‘var’ ".

I’m not seeing this error when I check your link.

Instead I get (later) \* **TypeError: Cannot use ‘in’ operator to search for ‘undefined’ in undefined**

The issue is with this code

```auto
 if (choose_2.status === PsychoJS.Status.STARTED && _pj.in_es6(choose_2.keys)) {
      choose_2.status = PsychoJS.Status.FINISHED;
  }

```

However, this doesn’t seem to match up with your Python code. Are you using an Auto translate code component?

You uploaded a .py file rather than a .psyexp file, so I can’t investigate further.

---

<div class="post-metadata">

### Author: ![zfy1394496908](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/zfy1394496908/32/33211_2.png) [@zfy1394496908](https://discourse.psychopy.org/u/zfy1394496908)
#### Post date: [March 28, 2022, 12:57pm UTC](https://discourse.psychopy.org/t/stuck-on-initialising-the-experiment-page/28232/5 "2022-03-28T12:57:54Z")

</div>

Thank you for your prompt reply! Yes, I solved the last issue, but it came up with other more problems. The JavaScript is losing almost all the definition codes? (var \*\*\*\*), but the python code is totally ok and the experiment can run on my laptop perfectly. I added all the variables myself in the Javascript. Now the problem is **TypeError: Cannot use ‘in’ operator to search for ‘undefined’ in undefined** , which I couldn’t find any solution.  
[dscrimination.psyexp](https://discourse.psychopy.org/uploads/short-url/uHgcekThGqyEw5GBWOKJZHfsJVk.psyexp) (181.9 KB)

```auto
  // *opt4_2* updates
    if (t >= 0.0 && opt4_2.status === PsychoJS.Status.NOT_STARTED) {
      // keep track of start time/frame for later
      opt4_2.tStart = t; // (not accounting for frame time here)
      opt4_2.frameNStart = frameN; // exact frame index
      
      opt4_2.setAutoDraw(true);
    }

     var _pj;
     function _pj_snippets(container) {
         function in_es6(left, right) {
             if (((right instanceof Array) || ((typeof right) === "string"))) {
                 return (right.indexOf(left) > (- 1));
             } else {
                 if (((right instanceof Map) || (right instanceof Set) || (right instanceof WeakMap) || (right instanceof WeakSet))) {
                     return right.has(left);
                 } else {
                     return (left in right);
                 }
             }
         }
         container["in_es6"] = in_es6;
         return container;
     }
    _pj = {};
    _pj_snippets(_pj);
    keys = psychoJS.eventManager.getKeys();
    if (keys.length) {
        if (_pj.in_es6("left", keys)) {
            slider_2.markerPos = (slider_2.markerPos - 1);
        } else {
            if (_pj.in_es6("right", keys)) {
                slider_2.markerPos = (slider_2.markerPos + 1);
            }
        }
    }
    psychoJS.experiment.addData("Rating", slider_2.markerPos);
    
 

```
