Good day!
I am writing a script as follows:
var prev = 0;
$(document).ready(function(){
dynamicListOne(length, prev);
});
function dynamicListOne(length, prev){
length++;
prev = length;
}
But prev is always 0.
How can i assign prev=length?
Thank you in advance
Your function takes
prevas an argument so inside the function the name points to a local variable instead of the global one. Just don’t add it as an argument to your function.And think carefully if you really really want a global variable.