So say I have a function like this:
function cookie(){
var a = 5;
function cat(){return a}
return cat()}
cookie() // 5
It works fine, it gets the variable a from the parent function. Now, when I define the cat function outside of cookie, it doesn't work like that
function cat(){return a}
function cookie(){
var a = 5;
return cat()}
cookie() // "a is not defined" error message
So this does make sense, but I'm still wondering how I could pass the local variable from the function cookie, to the function cat.
How do I go about making the local variable "a" from cookie to also be defined in cat, as a local variable?