if(e.target.className === "deleteNode") {
console.log(e.target.parentNode);
let index = allNodes.findIndex(el => {
console.log("E: "+e.target.parentNode.lastChild.innerHTML);
console.log("El: "+el.lastChild.innerHTML);
console.log("compare: "+el.lastChild.innerHTML.localeCompare(e.target.parentNode.lastChild.innerHTML));
el.lastChild.innerHTML.localeCompare(e.target.parentNode.lastChild.innerHTML))
});
console.log("index: "+index);
The above is called from a click listener. Click happens on a button inside a dynamically created div element. The last child of the div is a <p> node. I want to get the index of the first match for the value of the text inside that div. allNodes is an array declared at the top of the script.
I have tried using the === comparator but same result. The 2 strings are identical but findIndex() is failing (returning -1)