# ReferenceError: round is not defined

**URL:** <https://discourse.psychopy.org/t/referenceerror-round-is-not-defined/12945>\
**Category:** Online experiments\
**Created:** [May 1, 2020, 8:31pm UTC](https://discourse.psychopy.org/t/referenceerror-round-is-not-defined/12945 "2020-05-01T20:31:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Long\_Yi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/long_yi/32/10272_2.png) [@Long\_Yi](https://discourse.psychopy.org/u/Long_Yi)\
**Post date:** [May 1, 2020, 8:31pm UTC](https://discourse.psychopy.org/t/referenceerror-round-is-not-defined/12945/1 "2020-05-01T20:31:35Z")

</div>

Description of the problem:  
Hi ppl I am new to PsychoPy and I encountered the error “ **ReferenceError: round is not defined** ” while running my problem on Pavlovia.  
I suspect it is something wrong with this here: “frameDur = 1.0/Math.round(expInfo[‘frameRate’]);”, but I have no clue how to fix it.  
Will appreciate any help : )

---

<div class="post-metadata">

**Author:** ![jonathan.kominsky](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jonathan.kominsky](https://discourse.psychopy.org/u/jonathan.kominsky)\
**Post date:** [May 2, 2020, 3:59pm UTC](https://discourse.psychopy.org/t/referenceerror-round-is-not-defined/12945/2 "2020-05-02T15:59:23Z")

</div>

Is that from a code component or just from the compiled experiment?

In either case, it would be helpful to see the full code. If you go to “view code” from your experiment page and link it here, we can have a look. You will need to make the repository public, so on that page, go to settings-\>general-\>permissions and set it to public before linking it.

---

<div class="post-metadata">

**Author:** ![Long\_Yi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/long_yi/32/10272_2.png) [@Long\_Yi](https://discourse.psychopy.org/u/Long_Yi)\
**Post date:** [May 3, 2020, 3:31pm UTC](https://discourse.psychopy.org/t/referenceerror-round-is-not-defined/12945/3 "2020-05-03T15:31:16Z")

</div>

Link to my repository: [https://gitlab.pavlovia.org/LongYI/ver3](https://gitlab.pavlovia.org/LongYI/ver3)  
Thanks Kominsky, appreciate it.

---

<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:** [May 3, 2020, 11:55pm UTC](https://discourse.psychopy.org/t/referenceerror-round-is-not-defined/12945/4 "2020-05-03T23:55:58Z")

</div>

You have

text.setText(round(prac\_cate, 2));  
and  
intvl\_cd\_txt.setText(round(countdown, 2));

You should add a round function in an initial JS codeblock for cases where the autotranslate fails.

Note that in Javascript you can’t round to two decimal places so you should, for example, use text.setText(round(prac\_cate\*100)/100);

> **[PsychoPy Python to Javascript crib sheet](https://docs.google.com/document/d/13jp0QAqQeFlYSjeZS0fDInvgaDzBXjGQNe4VNKbbNHQ/edit?usp=sharing)**
>
> PsychoPy Python to Javascript crib sheet Compiled by Wakefield Morys-Carter, Oxford Brookes University PsychoPy 2020 has an automatic Python to Javascript translation tool. This document contains information about code that is not translated...

Best wishes,

Wakefield

---

<div class="post-metadata">

**Author:** ![Long\_Yi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/long_yi/32/10272_2.png) [@Long\_Yi](https://discourse.psychopy.org/u/Long_Yi)\
**Post date:** [May 4, 2020, 1:32am UTC](https://discourse.psychopy.org/t/referenceerror-round-is-not-defined/12945/5 "2020-05-04T01:32:31Z")

</div>

Thank you, the answer and the crib sheet are really helpful 🙂
