So I have got this error saying 'Uncaught TypeError: Cannot read properties of undefined (reading 'style')' on line 97, a.style.textDecoration = 'line-through'; Can someone explain to me why it happened? I think I had 'a' defined in the same function. Thank you in advance!
I am trying to write a to do list. And when I click on the checkbox in front of the task, the task would be crossed out. Here is the code of the function with error...
function crossing(x){
array1.forEach(function process(y){
const a = document.getElementById(y.code).getElementsByTagName('div')[0];
if(y.code===x.target.id){
**a.style.textDecoration = 'line-through';**
}
})
}
Here is the link for all the codes... https://jsfiddle.net/PhilipWoo/x8dewa0s/