Having trouble using the variable counter from one function in a different file? In the first function, I defined counter without using "var" thinking it would make it a global variable. But for some reason, it doesn't seem to work. Help needed!
//function used in symptoms.html
function checkboxes(){
counter = parseInt(document.querySelectorAll('input[type="checkbox"]:checked').length); //counter should be global var?
if (counter>=10){
location.href='end.html';
}else{
location.href='state.html';
}
}
//function used in another file
function statedegree(x){
var conclusion=x*counter;//uses counter var from checkboxes()
if (conclusion>=18){
location.href= 'end.html';
} else{
location.href='end1.html';
}
}