function fetchValue(){
var bill = JSON.parse(localStorage.getItem('bill'));
var result = document.getElementById('total');
result.innerHTML='';
var total=0;
for(var i=0;i < bill.length;i++){
var items= bill[i].items;
var date= bill[i].date;
var price= bill[i].price;
total+= parseFloat(price);
}
}
In the above code I have value total
which is inside function fetchValue()
in the JavaScript file named main.js
.
Can i access total
in another JavaScript file calculate.js
?
how?