Hi, I have created a clock face and it works well, I am now trying to add a countdown feature, I have all the math and coding issues sorted, but I need to pass a couple of variables through multiple functions, can I create a global variable that will work across multiple functions?
Answered! Go to the Best Answer.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Yes, you certainly can.
let globX = 0;
function setX() {
globX = 1;
}
function setAnotherX() {
globX = 2;
}
Or you can just pass it around the functions.
function setX() {
let someX = 1;
someX = setAnotherX(someX)
}
function setAnotherX(valX) {
return valX++;
}
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Yes, you certainly can.
let globX = 0;
function setX() {
globX = 1;
}
function setAnotherX() {
globX = 2;
}
Or you can just pass it around the functions.
function setX() {
let someX = 1;
someX = setAnotherX(someX)
}
function setAnotherX(valX) {
return valX++;
}
Best AnswerYeah I thought it should be like that, been doing the first option and it is not working, I am unsure why. might try a rewrite and see if that fixes my issues.
Thanx.
Best Answer