# Pavlovia error - Cannot read property '0' of undefined

**URL:** https://discourse.psychopy.org/t/pavlovia-error-cannot-read-property-0-of-undefined/14116
**Category:** Online experiments
**Created:** [June 9, 2020, 11:50am UTC](https://discourse.psychopy.org/t/pavlovia-error-cannot-read-property-0-of-undefined/14116 "2020-06-09T11:50:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pinar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/pinar/32/8016_2.png) [@pinar](https://discourse.psychopy.org/u/pinar)
#### Post date: [June 9, 2020, 11:50am UTC](https://discourse.psychopy.org/t/pavlovia-error-cannot-read-property-0-of-undefined/14116/1 "2020-06-09T11:50:36Z")

</div>

URL of experiment: [Sign in · GitLab](https://gitlab.pavlovia.org/pinartoptas/timingpriors)

Description of the problem: Hello all, it’s going to be pretty straightforward. I get this error even though I don’t have anything set to ‘0’

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/a/1/a1a0d5ee80a4c2945cf90049a9c8019b26f7f8f8.png)  
What should I do?

---

<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: [June 9, 2020, 12:34pm UTC](https://discourse.psychopy.org/t/pavlovia-error-cannot-read-property-0-of-undefined/14116/2 "2020-06-09T12:34:25Z")

</div>

The issue is, I believe, that there is a problem with ite1\_loop

Do you have nReps sent to blank?

---

<div class="post-metadata">

### Author: ![pinar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/pinar/32/8016_2.png) [@pinar](https://discourse.psychopy.org/u/pinar)
#### Post date: [June 9, 2020, 1:38pm UTC](https://discourse.psychopy.org/t/pavlovia-error-cannot-read-property-0-of-undefined/14116/3 "2020-06-09T13:38:23Z")

</div>

You mean set\* to? No, I don’t.  
The first line in the following code seems to be the problematic line. Does js starts from 0 in its for loops and throws the error 0 is not defined?  
By the way, the same code structure was executed without a problem for an earlier loop in which I defined nReps with number rather than a variable name from xlsx. Can that be a problem?

```auto
  for (const thisIte1_loop of ite1_loop) {
    const snapshot = ite1_loop.getSnapshot();
    thisScheduler.add(importConditions(snapshot));
    thisScheduler.add(iteration1RoutineBegin(snapshot));
    thisScheduler.add(iteration1RoutineEachFrame(snapshot));
    thisScheduler.add(iteration1RoutineEnd(snapshot));
    thisScheduler.add(endLoopIteration(thisScheduler, snapshot));
  }

```

---

<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: [June 9, 2020, 1:43pm UTC](https://discourse.psychopy.org/t/pavlovia-error-cannot-read-property-0-of-undefined/14116/4 "2020-06-09T13:43:54Z")

</div>

I think nReps is the issue.

Did you put a $ in front of the variable name?

**If the $ is shown in the PsychoPy dialogue box it probably isn’t needed in PsychoPy and may cause an error online.**

> **[PsychoPy Python to Javascript crib sheet](https://docs.google.com/document/d/13jp0QAqQeFlYSjeZS0fDInvgaDzBXjGQNe4VNKbbNHQ/edit?usp=sharing)**
>
> PsychoPy version 2020.1.3Python to JavaScript Crib Sheet Compiled by Wakefield Morys-Carter, Oxford Brookes UniversityPlease retweet Psych\_Stats. PsychoPy 2020 has an automatic Python to Javascript translation tool. This document contains...

---

<div class="post-metadata">

### Author: ![pinar](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/pinar/32/8016_2.png) [@pinar](https://discourse.psychopy.org/u/pinar)
#### Post date: [June 9, 2020, 1:49pm UTC](https://discourse.psychopy.org/t/pavlovia-error-cannot-read-property-0-of-undefined/14116/5 "2020-06-09T13:49:17Z")

</div>

I noticed that and removed the $ signs. That solved my trialNum (nReps variable name) undefined issue. Thanks.

Though I solved this post’s problem too I really don’t understand why. 😃

I have 7 routines nested in loops. All their nReps come from an xlsx file. The first routine threw the error 0 undefined, so I changed nReps to a number instead of a variable from excel, but I only did this for the first routine to see if that’s the problem. It worked and I didn’t even have to touch the other 6 routines.
