Write a JS function that finds the first table in a document and sums the values in the last column. The result is then displayed in an element with ID "sum".
Input/Output:
There will be no input/output, your program should instead modify the DOM of the given HTML document.
Sample HTML:
<table>
<tbody>
<tr><th>Product</th><th>Cost</th></tr>
<tr><td>Beer</td> <td>2.88</td></tr>
<tr><td>Fries</td> <td>2.15</td></tr>
<tr><td>Burger</td> <td>4.59</td></tr>
<tr><td>Total:</td> <td id="sum"></td></tr>
</tbody>
</table>
<button onclick="sum()">Sum</button>
Examples:
