Make your own free website on Tripod.com

The BadAdd

<script>
//BadAdd
//Demonstrates a potential pitfall
//Spencer Williams, 09/07

var meal;
var tip = meal * .15;
var total = meal + tip;

//get the cost of the meal from the user
meal = prompt("How much was the meal?");

var tip = meal * .15;
var total = meal + tip;

alert ("the meal is $" + meal);
alert ("the tip is $" + total);
alert ("Total bill: $" + total);
</script>