Created
June 15, 2023 02:04
-
-
Save vituchon/41b97519d7e9dc77c93ba24af0930160 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sumTableCells(tableId,cellIndex) { | |
var table = document.getElementById(tableId); | |
debugger; | |
let subTotal = Array.from(table.rows).reduce((total, row) => { | |
const textContent = row?.cells[cellIndex]?.textContent | |
return total + textContent ? parseInt(textContent.split(" ")[1].replace(",",".")) : 0 | |
}, 0); | |
return subTotal | |
} | |
sumTableCells("table",5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment