código:
try { let before_column = allColumns[allColumns.indexOf(current_column) - 1].children; if (before_column[current_postition - 2] != undefined && before_column[current_postition - 2].children.length != 0) { if (before_column[current_postition - 2].children[0].className.split(" ")[1] == "blackpiece") { before_column[current_postition - 2].classList.add("attackedwhite"); knightAttacked.push(before_column[current_postition - 2]); } if (before_column[current_postition - 2].children[0].className.split(" ")[1] == "whitepiece") { before_column[current_postition - 2].classList.add("protectedwhite"); knightProtected.push(before_column[current_postition - 2]); } } else { before_column[current_postition - 2].classList.add("protectedwhite"); knightProtected.push(before_column[current_postition - 2]); } } catch (er){ console.log(er); }Error:
TypeError: before_column[(current_postition - 2)].classList.add no es una función
Conozco la función de alternar, pero necesito agregar para que funcione. Mi proyecto requiere la función de agregar y no se puede hacer con la función de alternar. Cualquier ayuda es muy apreciada.