Is there any how javascript or jquery to store values in the given variables while interacting through functions wuthout using global vars?
I made an example: http://jsfiddle.net/1fw2urks/3/
$(document).ready(function(){
start();
});
function start(){
var n = 0;
for (i = 0; i < 10; i++){
count(n);
}
alert(n);
}
function count(n){
countAgain(n);
}
function countAgain(n){
n += 1;
}
n var should come with value 10 if it worked, but it seems that we can't change the passed parameters value while in the function.
Is this affirmation right? (I did some research and i found this answer, but, I am stubborn)