# TypeError: Number.IsInteger is not a function

**URL:** <https://discourse.psychopy.org/t/typeerror-number-isinteger-is-not-a-function/37608>\
**Category:** Online experiments\
**Tags:** online, pavlovia\
**Created:** [November 16, 2023, 11:14pm UTC](https://discourse.psychopy.org/t/typeerror-number-isinteger-is-not-a-function/37608 "2023-11-16T23:14:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_CM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dan_cm/32/38195_2.png) [@Dan\_CM](https://discourse.psychopy.org/u/Dan_CM)\
**Post date:** [November 16, 2023, 11:14pm UTC](https://discourse.psychopy.org/t/typeerror-number-isinteger-is-not-a-function/37608/1 "2023-11-16T23:14:27Z")

</div>

URL of experiment: [WTK\_Newstories [PsychoPy]](https://run.pavlovia.org/socialdecisionlab/wtk_newstories)

Description of the problem:

This error (TypeError: Number.IsInteger is not a function) comes up I can’t work out the cause of it. It begins at the first point after instructions, trying to draw basic text to a screen. It does not matter if the text comes from an input file or if I just type it in the box. It works fine in PsychoPy, using the automatic translation to JS. I have been trying to troubleshoot for a few hours now, and I am still stumped. The developer view in the browser does not offer a clue as to where the error is happening, but it does suggest it is trying some conversion to numeric. Any help would be most appreciated.

1. context: “when converting an object to its numerical form”
2. error: TypeError: Number.parseFloat is not a function at convertToNumber

etc…

---

<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:** [November 17, 2023, 8:18am UTC](https://discourse.psychopy.org/t/typeerror-number-isinteger-is-not-a-function/37608/2 "2023-11-17T08:18:15Z")

</div>

Might the error occur as you enter a loop? If so, what is the value of nReps?

---

<div class="post-metadata">

**Author:** ![Dan\_CM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dan_cm/32/38195_2.png) [@Dan\_CM](https://discourse.psychopy.org/u/Dan_CM)\
**Post date:** [November 17, 2023, 9:12am UTC](https://discourse.psychopy.org/t/typeerror-number-isinteger-is-not-a-function/37608/3 "2023-11-17T09:12:36Z")

</div>

Yes, it only happens when the trial is happening with a loop. It takes an input file with 7 variables. nReps is 1. The Conditions file has 120 conditions across 7 columns, so in Psychopy is just runs through those as 120 trials. Perhaps there is another way to make it work with JS?

---

<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:** [November 17, 2023, 9:17am UTC](https://discourse.psychopy.org/t/typeerror-number-isinteger-is-not-a-function/37608/4 "2023-11-17T09:17:22Z")

</div>

I’ve just looked at the developer view and the error appears to be in this line

```auto
   this.buttons = Number.isInteger(buttons) ? buttons : 'which' in event && event.which;
   

```

Do you have button components or buttons defined in code?

---

<div class="post-metadata">

**Author:** ![Dan\_CM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dan_cm/32/38195_2.png) [@Dan\_CM](https://discourse.psychopy.org/u/Dan_CM)\
**Post date:** [November 17, 2023, 9:18am UTC](https://discourse.psychopy.org/t/typeerror-number-isinteger-is-not-a-function/37608/5 "2023-11-17T09:18:50Z")

</div>

Button components. Allowed keys are “right” and “left”, set as constant. Everything else is left as default. I will have a quick try with different button responses… hmm no dice. I have been adjusting the code a bit this morning. Currently, the error in developer view comes up at this point, but that changes if make the text not a variable:

newstory\_text.setText(story\_text);

---

<div class="post-metadata">

**Author:** ![Dan\_CM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dan_cm/32/38195_2.png) [@Dan\_CM](https://discourse.psychopy.org/u/Dan_CM)\
**Post date:** [November 17, 2023, 9:27am UTC](https://discourse.psychopy.org/t/typeerror-number-isinteger-is-not-a-function/37608/6 "2023-11-17T09:27:48Z")

</div>

Ah! One of the variables in the loop condition file was called “Number”. I changed that and it was fixed. Thanks so much for your time. The clue was in the ‘loop’ dependency 😄

---

<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:** [November 17, 2023, 9:38am UTC](https://discourse.psychopy.org/t/typeerror-number-isinteger-is-not-a-function/37608/7 "2023-11-17T09:38:02Z")

</div>

Ah yes. Number is already on my crib sheet as a variable name to avoid.

> **[PsychoPy Python to Javascript crib sheet 2023](https://docs.google.com/document/d/1TSEgiG3SeGSr7LWoRahTZm7vk_loU8zKoDQh2sV1KFw/edit#heading=h.9aaotovh825k)**
>
> PsychoPy version 2023.1.3Python to JavaScript Crib Sheet Compiled by Wakefield Morys-Carter, Oxford Brookes UniversityPlease share widely and follow Psych\_Stats on twitter. There have been significant improvements in the auto translation function in...
