How to add cell to all rows of a table with vanilla JavaScript?

I desire to add a table cell from the right of any last cell, of my table’s rows:

document.querySelectorAll("td").forEach((element) => {
    element.insertRow(-1);
});
<section class="allEnglishSections">
    <h2>Conditioning</h2>
    <table>
        <tr><th>English</tr></th>
        <tr><td>if</td></tr>
        <tr><td>else</td></tr>
    </table>
</section>

I get this error:

Error {
“message”: “Script error.”,
“filename”: “”,
“lineno”: 0,
“colno”: 0
}

but I don’t understand the problem from it; what is wrong?

Leave a Reply

Your email address will not be published. Required fields are marked *