Functions - Passing Data Back

Click the button to enter the amount.

Code Example

<script>
 function calcTot (merchTot) {
  var orderTot;
  if (merchTot >= 100) {
    orderTot = merchTot;
  }
  else if (merchTot < 50.01) {
    orderTot = merchTot + 5;
  }
  
  else {
    orderTot = merchTot + 5 + (.03 * (merchTot - 50));
  }
  return orderTot;
}

var merchTot = prompt("Enter a total amont in dollars", "52.00");

   alert("Your total is " + merchTot);
</script>