Skip to main content
Toby Culverwell's Blog

Tipping the JavaScript.

Tipping the JavaScript.

As a part of the Coders Guild Boot-camp on for Web Design and Development Skills, I studied and learnt about JavaScript. This post and the next few will demonstrate various key uses of JavaScript. Down below is a program that calculates the cost of the overall bill and from how much it originally cost and the percentage of tip that they will provide.

JavaScript Code

	let foodCost = prompt('Enter the cost of food:');
	let tipPercent = prompt('Percentage of cost to be tipped:');
	var tipAmount = (Number(foodCost) * Number(tipPercent))/ 100;
	var totalBill = Number(foodCost) + tipAmount;
	alert('Total bill is: £' + totalBill.toFixed(2));