Edit in JSFiddle

var loan = 100;
var interest = 0.05;

console.log(total(loan,interest));
console.log(total(200,0.03));
console.log(total(500,0.10));

var owed = total(loan,interest);
document.getElementById("total").innerText = owed;


function total(a,b){
		var calculated = a + (a*b);
    return calculated;
}
<!-- Easy JavaScript # 28 - Value Returning JavaScript Functions -->
<p>
Welcome to the 28th Easy JavaScript tutorial, part of <a href="http://www.easyprogramming.net">EasyProgramming.net</a>. We continue to look at custom functions by practicing functions which return something. 
</p>
<p>
Returning information is optional. Returned information is often used as values for variables. 
</p>

<h2>
Syntax of a function:</h2>

<p>
<code><pre>
  function nameOfFunction(parameter1, parameter2...){
    //declare local variables
    //do something with parameter 1
    //do something with parameter 2
    //do other things
    //return value (optional)
  }</pre>
</code>
</p>
<h2>
Invoking a function
</h2>
<code>
  <pre>nameOfFunction(argument1, argument2...);</pre>
</code>
<p>
<h2>
Let's practice:</h2>
You borrowed $100 with an interest rate of 5%.<br />
The total owed with interest is: $<span id="total">___</span>
<br /><br />