1

I have been doing sheet.stopTC(aVal)

and it seems to go fine, however here:

key: "stopTC",
value: function stopTC(z) {

  if (z == true) {
    z = false;
    console.log("cache started");
  } else {
    z = true;
    console.log("cache stopped");
  }
  return z;
}

//globals
aVal = false

the variable is globally set to false but when it comes back the aVal stays false instead of changing to true`.

Sorry I'm new to programming and can't get my head around it.

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Alexander Hemming
  • 753
  • 1
  • 6
  • 28
  • If you pass in a variable in a function and *reassign it*, you are not changing the variable outside the function. JavaScript is a pass by value language, so you cannot manipulate what the variable outside the function is, unless you address it directly, e.g., if you do `aVal = true` inside the function, and `aVal` is visible, then it will be changed. – VLAZ Oct 02 '19 at 11:20

1 Answers1

0

You should do aVal = sheet.stopTC(aVal) then it will became true