# Rounding RT feedback not working in Pavlovia/JS

**URL:** <https://discourse.psychopy.org/t/rounding-rt-feedback-not-working-in-pavlovia-js/27642>\
**Category:** Builder\
**Tags:** timing, code, online, pavlovia\
**Created:** [February 24, 2022, 3:22pm UTC](https://discourse.psychopy.org/t/rounding-rt-feedback-not-working-in-pavlovia-js/27642 "2022-02-24T15:22:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlyleannah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/carlyleannah/32/13011_2.png) [@carlyleannah](https://discourse.psychopy.org/u/carlyleannah)\
**Post date:** [February 24, 2022, 3:22pm UTC](https://discourse.psychopy.org/t/rounding-rt-feedback-not-working-in-pavlovia-js/27642/1 "2022-02-24T15:22:01Z")

</div>

I have a feedback loop to show participants if their response was correct and their response time (in seconds). The experiment will be run online, not locally. Everything works great when I run the experiment PsychoPy, but it is not working with Pavlovia.

The code component is currently set at Auto → JS. I have the following code in the Py section on the left:

```auto
if resp.corr:#stored on last run routine
  msg="Correct! Response time = "+str(round(resp.rt, ndigits=2))
else:
  msg="Oops! That was wrong."

```

– which PsychoPy auto-translated to JS, showing up on the right of the code component:

```auto
if (resp.corr) {
    msg = ("Correct! Response time = " + Math.round(resp.rt).toString());
} else {
    msg = "Oops! That was wrong.";
}

```

**What I already tried:**  
When I run the experiment locally on PsychoPy it works fine. However, when I sync it with Pavlovia and then run the experiment online, the rounding does not work. I already tried changing the Code Type on the component to JS only and used the following codes, which did not work:

```auto
if (resp.corr) {
    msg = ("Correct! Response time = " + Math.round(resp.rt).toString(3));
} else {
    msg = "Oops! That was wrong.";

```

```auto
if (resp.corr) {
    msg = ("Correct! Response time = " + Math.round(resp.rt).toFixed(3));
} else {
    msg = "Oops! That was wrong.";
}

```

Attaching a screenshot of what the code component window looks like in Builder. The codes not shown in the screenshot below are copied and pasted above.

 ![Screen Shot 2022-02-24 at 10.15.23 AM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/3/6/363b63bb41e3425e09be8d307b4ff9c0d2d6633c.jpeg)

---

<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:** [February 24, 2022, 4:40pm UTC](https://discourse.psychopy.org/t/rounding-rt-feedback-not-working-in-pavlovia-js/27642/2 "2022-02-24T16:40:48Z")

</div>

> [@carlyleannah](#):
>
> ```auto
> if (resp.corr) {
> msg = ("Correct! Response time = " + Math.round(resp.rt).toString(3));
> } else {
> msg = "Oops! That was wrong.";
> 
> ```

Try

```auto
if (resp.corr) {
    msg = ("Correct! Response time = " + Math.round(resp.rt, 3).toString());
} else {
    msg = "Oops! That was wrong.";

```

---

<div class="post-metadata">

**Author:** ![carlyleannah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/carlyleannah/32/13011_2.png) [@carlyleannah](https://discourse.psychopy.org/u/carlyleannah)\
**Post date:** [February 24, 2022, 6:08pm UTC](https://discourse.psychopy.org/t/rounding-rt-feedback-not-working-in-pavlovia-js/27642/3 "2022-02-24T18:08:17Z")

</div>

I tried following your suggestion:

```auto
if (resp.corr) {
    msg = ("Correct! Response time = " + Math.round(resp.rt, 3).toString());
} else {
    msg = "Oops! That was wrong.";

```

RT feedback is still rounding to one digit with no decimal place.

Code component screenshot in case it’s helpful:

 ![Screen Shot 2022-02-24 at 1.07.23 PM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/a/ea6456596fc19b2803c58d2b4b67e49d0fbc6502.png)

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [March 2, 2022, 10:00am UTC](https://discourse.psychopy.org/t/rounding-rt-feedback-not-working-in-pavlovia-js/27642/4 "2022-03-02T10:00:31Z")

</div>

Hello Carly

> [@carlyleannah](#):
>
> ```auto
> if (resp.corr) {
> msg = ("Correct! Response time = " + Math.round(resp.rt, 3).toString());
> } else {
> msg = "Oops! That was wrong.";
> 
> ```

try

```auto
if (resp.corr) {
    msg = ("Correct! Response time = " + round(resp.rt, 3).toString());
} else {
    msg = "Oops! That was wrong.";

```

Best wishes Jens

---

<div class="post-metadata">

**Author:** ![carlyleannah](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/carlyleannah/32/13011_2.png) [@carlyleannah](https://discourse.psychopy.org/u/carlyleannah)\
**Post date:** [March 2, 2022, 5:11pm UTC](https://discourse.psychopy.org/t/rounding-rt-feedback-not-working-in-pavlovia-js/27642/5 "2022-03-02T17:11:05Z")

</div>

It worked Thank you so much.
