I am bit confused as to why this function is not working.
It is supposed to check if an input is during a certain time and update the count for that time period only. It should be a simple task but I might be overthinking this function.
the idea is that it will add count to specific time areas. so anything added during 10.00-11.00 will add up during that time slot and next it will add count in the next time slots.
function updateCount(){
let min = d.getHours()
if(time > 10 && time < 11 ){
barOne++;
console.log('bar one: '+barOne);
bar1.style.height= barOne*1+"em";
localStorage.setItem("one", barOne)
}
else if(time > 11 && time < 12){
barTwo++;
console.log(barTwo)
bar2.style.height= barTwo*1+"em";
localStorage.setItem("two", barTwo)
}
else if(time > 12 && time < 13){
barThree++;
console.log(barThree)
bar3.style.height= barThree*1+"em";
localStorage.setItem("three", barThree)
}
else if(time > 13 && time < 14){
barFour++;
console.log(barFour)
bar4.style.height= barFour*1+"em";
localStorage.setItem("four", barFour)
}
else if(time > 14 && time < 15){
barFive++;
console.log(barFive)
bar5.style.height= barFive*1+"em";
localStorage.setItem("five", barFive)
}
else if(time > 15 && time < 16){
barSix++;
console.log(barSix)
bar6.style.height= barSix*1+"em";
localStorage.setItem("six", barSix)
}
else if(time > 16 && time < 17){
barSeven++;
console.log(barSeven)
localStorage.setItem("five", barSeven)
bar7.style.height= barSeven*1+"em";
}
else if(time > 17 && time < 18){
barEight++;
console.log(barEight);
localStorage.setItem('eight', barEight);
bar8.style.height= barEight*1+"em";
}
else if(time > 18 && time < 19){
barNine++;
console.log(barNine);
localStorage.setItem('nine', barNine);
bar9.style.height= barNine*1+"em";
}
else{
console.log(`it's ${min} it's outside range`)
}
}
trying to the count to update a specific time period.