Cant figure this out


If I redefine a global variable inside a function, is there a way to make that effect the global value as well?


yep, pretty easy:

var variable = 5;
var example = function(){
  variable += 5;

don't use a var keyword in the function, this will make the variable local (only exist inside the function), without the var keyword the global variable will be updated


Thanks! That makes sense.