I have written a very simple java script code. I want to change the value of global variable using a local function. I want that when I call the
//here the value should be 2
Your code works fine! You have to invoke
vari() though, but you know that, right? You cannot expect variables to change, if you do not call the functions that change the values!