Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function newHouse(input) {
- let typeFlowers = input.shift();
- let qtyFlowers = Number(input.shift());
- let bugdet = Number(input.shift());
- let moneyLeft = 0;
- let moneyNeeded = 0;
- let totalPrice = 0;
- if (typeFlowers == "Roses") {
- if (qtyFlowers > 80) {
- totalPrice = (qtyFlowers * 5) * 0.9;
- } else {
- totalPrice = qtyFlowers * 5;
- }
- } else if(typeFlowers == "Dahlias") {
- if (qtyFlowers > 90) {
- totalPrice = (qtyFlowers * 3.80) * 0.85;
- } else {
- totalPrice = qtyFlowers * 3.80;
- }
- } else if(typeFlowers == "Tulips") {
- if (qtyFlowers > 80) {
- totalPrice = (qtyFlowers * 2.80) * 0.85;
- } else {
- totalPrice = qtyFlowers * 2.80;
- }
- } else if(typeFlowers == "Narcissus") {
- if (qtyFlowers < 120) {
- totalPrice = (qtyFlowers * 3) * 1.15;
- } else {
- totalPrice = qtyFlowers * 3;
- }
- } else if(typeFlowers == "Gladiolus") {
- if (qtyFlowers < 80) {
- totalPrice = (qtyFlowers * 2.50) * 1.20;
- } else {
- totalPrice = qtyFlowers * 2.50;
- }
- }
- if (bugdet >= totalPrice) {
- console.log(`Hey, you have a great garden with ${qtyFlowers} ${typeFlowers} and ${(bugdet - totalPrice).toFixed(2)} leva left.`);
- } else {
- console.log(`Not enough money, you need ${(totalPrice - bugdet).toFixed(2)} leva more.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement