02-10-2019 15:07
02-10-2019 15:07
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 Answer02-11-2019 09:26 - edited 02-11-2019 09:28
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.
02-11-2019 09:26 - edited 02-11-2019 09:28
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 Answer02-10-2019 22:47
Platinum Fitbit Product Experts share support knowledge on the forums and advocate for the betterment of Fitbit products and services. Learn more
02-11-2019 09:26 - edited 02-11-2019 09:28
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.
02-11-2019 09:26 - edited 02-11-2019 09:28
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 Answer02-11-2019 13:11
02-11-2019 13:11
Yeah 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