JS HTML Table Table Extrait Data

const extractData = (tableId, mapper) => {
  const myTab = document.getElementById(tableId);
  if (myTab) {
    const data = [...myTab.rows].map((r) => [...r.cells].map((c) => c.innerText));
    return data.map(mapper);
  }
};

// Call the function and do whatever you want with the data
const data = extractData('target-table', (x) => ({
  name: x[0]
}));
florinrelea