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.
02-11-2019 09:26 - edited 02-11-2019 09:28
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++;
}
02-10-2019 22:47
02-11-2019 09:26 - edited 02-11-2019 09:28
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++;
}
02-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.