Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fuelTank2(input) {
- let fuel = input.shift();
- let liters = +input.shift();
- let card = input.shift();
- let price = 0;
- if (fuel === "Gas") {
- price = 0.93;
- if (card === "Yes") {
- price -= price * 0.08;
- }
- } else if (fuel === "Gasoline") {
- price = 2.22;
- if (card === "Yes") {
- price -= price * 0.18;
- }
- } else if (fuel === "Diesel") {
- price = 2.33;
- if (card === "Yes") {
- price -= price * 0.12;
- }
- }
- if (liters >= 20 && liters <= 25) {
- price -= price * 0.08;
- } else if (liters > 25) {
- price -= price * 0.1;
- }
- price1 = price * liters;
- console.log(`${price1.toFixed(2)} lv.`);
- }
- fuelTank2(["Gas", "30", "Yes"]);
- fuelTank2(["Gasoline", "25", "No"]);
- fuelTank2(["Diesel", "19", "No"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement