I am trying to calculate the sum of my 'var time' so that it can display the total on my table. Could someone tell me how do I go about doing this?
<td>
<h3 id="Luke Hours">
<script>
var time = [2, 0.5, 1];
document.getElementById("Luke Hours").innerHTML = time;
</script>
</h3>
<h4 id="Luke Time">
<script>
var text = "";
var i;
for (i = 0; i < time.length; i++) {
text += time[i] + "<br>";
}
document.getElementById("Luke Time").innerHTML = text;
</script>
</h4>
</td>
The number in red is the sum and the ones in black is each individual number. I want it to look like this.
"` you are doing string concatenation – Patrick Evans Feb 02 '16 at 03:37