I keep getting “undefined” as result from returning the variable inside a function.
This is the code:
var nloads = 1;
function something(loc) {
console.log(nloads); // returns 1
}
function changeSection(loc) {
console.log(nloads); // Returns undefined
nloads = nloads + 1;
temp = nloads;
}
What’s wrong with it?/What may be causing the problem?
Please check this pic of code.