Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(fuelType, fuelVolume, clubCard){
- fuelVolume = Number(fuelVolume);
- let gasolineLiterPrice, gasLiterPrice, dieselLiterPrice;
- gasolineLiterPrice = 2.22;
- gasLiterPrice = 0.93;
- dieselLiterPrice = 2.33;
- if(clubCard === 'Yes') {
- gasolineLiterPrice -= 0.18;
- gasLiterPrice -= 0.08;
- dieselLiterPrice -= 0.12;
- }
- let gasolinePrice, gasPrice, dieselPrice;
- gasolinePrice = gasolineLiterPrice * fuelVolume;
- gasPrice = gasLiterPrice * fuelVolume;
- dieselPrice = dieselLiterPrice * fuelVolume;
- if(fuelVolume > 20 && fuelVolume <= 25){
- gasolinePrice *= 0.92;
- gasPrice *= 0.92;
- dieselPrice *= 0.92;
- } else if(fuelVolume > 25) {
- gasolinePrice *= 0.9;
- gasPrice *= 0.9;
- dieselPrice *= 0.9;
- }
- if(fuelType === 'Gasoline') {
- console.log(`${gasolinePrice.toFixed(2)} lv.`);
- } else if (fuelType === 'Gas') {
- console.log(`${gasPrice.toFixed(2)} lv.`);
- } else if (fuelType === 'Diesel') {
- console.log(`${dieselPrice.toFixed(2)} lv.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement