JSFiddle - React, Tailwind, and code Playground

by Ramya Ranganathan

HTML

<H1>Functions </H1>
<H3>This is a practice set to find the Total of all arguments.</H3>

<p>Arguments are passed by value</p>
<p>The function only gets to know the values, not the argument's locations.</p>

<H2> Output of this will be: </H2>
<p id="total"></p>

JavaScript

x = total(150, 100, 220, 145, 84, 96,120);

function total() {
    var i, sum = 0;
    for(i = 0; i < arguments.length; i++) {
        sum += arguments[i];
    }
    return sum;
} 
document.getElementById("total").innerHTML =
total(150, 100, 220, 145, 84, 96,120);