# Javascript tip calculations

**URL:** <https://forum.kirupa.com/t/javascript-tip-calculations/221149>\
**Category:** web dev\
**Created:** [April 1, 2007, 11:22pm UTC](https://forum.kirupa.com/t/javascript-tip-calculations/221149 "2007-04-01T23:22:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thats\_all\_folks](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@thats\_all\_folks](https://forum.kirupa.com/u/thats_all_folks)\
**Post date:** [April 1, 2007, 11:22pm UTC](https://forum.kirupa.com/t/javascript-tip-calculations/221149/1 "2007-04-01T23:22:41Z")

</div>

I’m teaching my self java and have run into a bump, I was trying to make an prompt box that will ask for your bill total and then times it by .20 for the tip and display in a alert box how much the tip will be based on the bill. I tried searching google first but have had no luck.

Cheers and thanks for any input.

\<script type=“text/javascript” language=“javascript1.5”\>  
\<!-- HIDE FROM OLDER BROWSERS  
function tipCal(myTip, myBill){  
var myTip = .20;  
return myTip \* myBill;  
}  
// --\>  
\</script\>  
\</head\>  
\<body\>  
\<script type=“text/javascript” language=“javascript1.5”\>  
\<!-- HIDE FROM OLDER BROWSERS  
var yourBill=eval(prompt(“How much is your bill?”, “”));

var tipRate = tipCal(myTip, myBill);  
//var tipRate = tipCal(yourTip, yourBill);

alert("Your tip will be: " + tipRate);

// --\>  
\</script\>
