02-10-2019 15:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-10-2019 15:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
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.

- Labels:
-
App Gallery - Clock
Accepted Solutions
02-11-2019 09:26 - edited 02-11-2019 09:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-11-2019 09:26 - edited 02-11-2019 09:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-10-2019 22:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hello @deaks007 I've moved your post into the app development board.
02-11-2019 09:26 - edited 02-11-2019 09:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-11-2019 09:26 - edited 02-11-2019 09:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-11-2019 13:11
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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.

