// on button lick set variable called testvariable1 to 2
var testvariable1 = 2;
// copy variable testvariable1 to testvariable2 to localstorage for use on page load
var testvariable2 = testvariable1;
localStorage.setItem("testvariable2", testvariable2);
});
// *********** button click event ***********
Is there better way to copy a variable from button click event to be available after a page reload?