javascript - How to make a chrome.storage.local variable increase 1 in each loop? -


function inc() {     chrome.storage.local.get("value",function(item){         chrome.storage.local.set({"value":item["value"]+1},function(){});     }); } for(var i=0;i<5;i++) {     inc(); } 

this chrome extension's inject.js,and "value" number,when refreshed page,it increase one.so try add alert(); statement above inc statement,the "value" increase 5,is there way increase 5?

i think should this:

function inc() {     chrome.storage.local.get('value', function(item) {         chrome.storage.local.set({'value' : (item.value + 1)},function(){});     }); }  for(var i=0;i<5;i++) {     inc(); } 

Comments