I want to use the same variable in 2 javascript files modify it in both files and get the updated value to both files. I tried this. But it doesn't worked.
first.js
let marks = 0;
function func1() {
function add() {
marks = marks + 5;
alert(marks);
window.location.replace("second.html");
}
return {
add:add;
}
}
export default func1;
second.js
import func1 from '../first';
func1().add();
function func2() {
function add2() {
marks = marks + 5;
alert(marks);
window.location.replace("third.html");
}
return {
add2:add2;
}
}
export default func2;