Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pipedVal (input){
- let flowersType = (input.shift());
- let flowersCount = Number(input.shift());
- let flowersBudget = Number(input.shift());
- let flowerPrice;
- let allFlowersPrice;
- let moneyLeft;
- let neededMoney;
- let nonFinalPrice;
- if (flowersType == "Roses" && flowersCount <= 80){
- flowerPrice = 5;
- allFlowersPrice = (flowerPrice*flowersCount);
- if (allFlowersPrice < flowersBudget){
- moneyLeft = (flowersBudget - allFlowersPrice);
- console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
- }
- if (allFlowersPrice > flowersBudget){
- neededMoney = (allFlowersPrice - flowersBudget);
- console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
- }
- }
- if (flowersType == "Roses" && flowersCount > 80){
- flowerPrice = 5;
- nonFinalPrice = ((flowerPrice*flowersCount));
- allFlowersPrice = (nonFinalPrice - (nonFinalPrice*0.1));
- if (allFlowersPrice < flowersBudget){
- moneyLeft = (flowersBudget - allFlowersPrice);
- console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
- }
- if (allFlowersPrice > flowersBudget){
- neededMoney = (allFlowersPrice - flowersBudget);
- console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
- }
- }
- if (flowersType == "Dahlias" && flowersCount <= 90){
- flowerPrice = 3.80;
- allFlowersPrice = (flowerPrice*flowersCount);
- if (allFlowersPrice < flowersBudget){
- moneyLeft = (flowersBudget - allFlowersPrice);
- console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
- }
- if (allFlowersPrice > flowersBudget){
- neededMoney = (allFlowersPrice - flowersBudget);
- console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
- }
- }
- if (flowersType == "Dahlias" && flowersCount > 90){
- flowerPrice = 3.80;
- nonFinalPrice = ((flowerPrice*flowersCount));
- allFlowersPrice = (nonFinalPrice - (nonFinalPrice*0.15));
- if (allFlowersPrice < flowersBudget){
- moneyLeft = (flowersBudget - allFlowersPrice);
- console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
- }
- if (allFlowersPrice > flowersBudget){
- neededMoney = (allFlowersPrice - flowersBudget);
- console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
- }
- }
- if (flowersType == "Tulips" && flowersCount <= 80){
- flowerPrice = 2.80;
- allFlowersPrice = (flowerPrice*flowersCount);
- if (allFlowersPrice < flowersBudget){
- moneyLeft = (flowersBudget - allFlowersPrice);
- console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
- }
- if (allFlowersPrice > flowersBudget){
- neededMoney = (allFlowersPrice - flowersBudget);
- console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
- }
- }
- if (flowersType == "Tulips" && flowersCount > 80){
- flowerPrice = 2.80;
- nonFinalPrice = ((flowerPrice*flowersCount));
- allFlowersPrice = (nonFinalPrice - (nonFinalPrice*0.15));
- if (allFlowersPrice < flowersBudget){
- moneyLeft = (flowersBudget - allFlowersPrice);
- console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
- }
- if (allFlowersPrice > flowersBudget){
- neededMoney = (allFlowersPrice - flowersBudget);
- console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
- }
- }
- if (flowersType == "Narcissus" && flowersCount >= 120){
- flowerPrice = 3;
- allFlowersPrice = (flowerPrice*flowersCount);
- if (allFlowersPrice < flowersBudget){
- moneyLeft = (flowersBudget - allFlowersPrice);
- console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
- }
- if (allFlowersPrice > flowersBudget){
- neededMoney = (allFlowersPrice - flowersBudget);
- console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
- }
- }
- if (flowersType == "Narcissus" && flowersCount < 120){
- flowerPrice = 3;
- nonFinalPrice = ((flowerPrice*flowersCount));
- allFlowersPrice = (nonFinalPrice + (nonFinalPrice*0.15));
- if (allFlowersPrice < flowersBudget){
- moneyLeft = (flowersBudget - allFlowersPrice);
- console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
- }
- if (allFlowersPrice > flowersBudget){
- neededMoney = (allFlowersPrice - flowersBudget);
- console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
- }
- }
- if (flowersType == "Gladiolus" && flowersCount >= 80){
- flowerPrice = 2.50;
- allFlowersPrice = (flowerPrice*flowersCount);
- if (allFlowersPrice < flowersBudget){
- moneyLeft = (flowersBudget - allFlowersPrice);
- console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
- }
- if (allFlowersPrice > flowersBudget){
- neededMoney = (allFlowersPrice - flowersBudget);
- console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
- }
- }
- if (flowersType == "Gladiolus" && flowersCount < 80){
- flowerPrice = 2.50;
- nonFinalPrice = ((flowerPrice*flowersCount));
- allFlowersPrice = (nonFinalPrice + (nonFinalPrice*0.2));
- if (allFlowersPrice < flowersBudget){
- moneyLeft = (flowersBudget - allFlowersPrice);
- console.log (`Hey, you have a great garden with ${flowersCount} ${flowersType} and ${moneyLeft.toFixed(2)} leva left.`);
- }
- if (allFlowersPrice > flowersBudget){
- neededMoney = (allFlowersPrice - flowersBudget);
- console.log(`Not enough money, you need ${neededMoney.toFixed(2)} leva more.`)
- }
- }
- }
- pipedVal (['Narcissus','119','360'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement