Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Does array.find not work in JS for FitBit?

Given this array:

 

const FIB_SEQ = [0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89];

 

shouldn't this work?

 

const found = FIB_SEQ.find((element) => element > 45);

 

The error I'm getting is "App: Unhandled exception: TypeError: Expected a function." 

 

I tested this in a code playground and it works as expected there. Is there some limitation in the FitBit implementation of JS? I feel like I'm missing something very simple here... having the same problem with array.indexOf as well.

Best Answer
0 Votes
5 REPLIES 5

On the watch, you have to limit yourself to ES5.1 (mostly).

Peter McLennan
Gondwana Software
Best Answer

Ah, okay. Thank you!

You said, "mostly..." Is there a guide to what is/isn't actually available?

Best Answer
0 Votes

I don't know of any reference on that, although it would be good to have.

 

There is some support for async/await and fetch.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

@Gondwana wrote:

I don't know of any reference on that, although it would be good to have.

 

There is some support for async/await and fetch.


Yes, mostly I just try it. They've actually implemented more than they've documented, though there are some idiosyncrasies.

 

On a positive note, if the results seem weird there's usually some information in the SDK forum about it.

Best Answer

Just to point some official documentation:

 

https://dev.fitbit.com/build/guides/application/#javascript

 

There it says it's ES5, with the JerryScript engine https://github.com/jerryscript-project/jerryscript

 

As you noticed there are also some additions like Promises

Best Answer