Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function club(input) {
- let target = Number(input[0]);
- let nameCocktail = input[1];
- let cocktailNum = parseInt(input[2]);
- let index = 1;
- let totalPrice = 0;
- let lengthCoctail = input[index];
- while(index < input.length) {
- let nameCocktail = input[index];
- if (nameCocktail === "Party!") {
- console.log(`We need ${(target - sum).toFixed(2)} leva more.`);
- break;
- }
- }
- let cocktailNum = Number(input[index + 1]);
- let totalPrice = (nameCocktail.length) * cocktailNum;
- if (totalPrice % 2 !== 0) {
- totalPrice = totalPrice * 0.75;
- }
- sum = sum + totalPrice;
- index += 2;
- if (sum >= target) {
- break;
- }
- if (sum < target) {
- console.log(`Club income " + sum.toFixed(2) + " leva.`);
- } else {
- console.log("Target acquired");
- console.log("Club income " + sum.toFixed(2) + " leva.");
- }
- }
- club("500", "Bellini", "6", "Bamboo", "7", "Party!");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement