04-23-2021 05:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-23-2021 05:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
On one of my clock faces, I would like to simplify the amount steps a user has. Basically, if the user has 0-1,000 steps, it will display a 0, if the user has 1,000-2,000 steps, it will display a 1, if the user has 2,000-3,000 steps, it will display a 2, and so on and so forth. If the user has over 10,000 steps, it will just display a 10. I know that I will need if-then statements, but I am not sure how to do so. Any suggestions?
Answered! Go to the Best Answer.

Accepted Solutions
04-23-2021 14:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-23-2021 14:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
You could indeed use if-then, but I wouldn't. I'd mess around with something like
Math.floor(steps/1000)
Gondwana Software

04-23-2021 14:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-23-2021 14:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
You could indeed use if-then, but I wouldn't. I'd mess around with something like
Math.floor(steps/1000)
Gondwana Software

04-26-2021 05:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-26-2021 05:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thank you so much. Your solution seems to make sense. However, that would give me a decimal number. Is there a way to not include the numbers after the decimal point? I know there is an option to set the <text-length> but according to the Fitbit guides, the number will always be rounded to a multiple of 4. If you know a way, would you mind giving me the code fully written out? I am not a great programmer, so I am not quite sure what to do.

04-26-2021 13:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-26-2021 13:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number
Gondwana Software

04-28-2021 06:20 - edited 04-28-2021 08:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-28-2021 06:20 - edited 04-28-2021 08:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Thank you so much. I read through the reference page, and it was very helpful. I figured out how to set the text length to not include the numbers after the decimal point. It was quite simple, actually.
04-28-2021 08:08 - edited 10-26-2021 08:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

04-28-2021 08:08 - edited 10-26-2021 08:02
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
For those curious, here is the code I used:
let steps = (today.adjusted.steps || 0);
const lvlsteps = document.getElementById("lvlsteps");
lvlsteps.text = `Level: ${Math.floor(steps/1000)}`;
04-28-2021 13:38
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


04-28-2021 13:38
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Nice; well done!
Gondwana Software

