Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function carToGo(input) {
- let budget = parseFloat(input[0]);
- let season = input[1];
- let car = 'Jeep';
- let carClass = 'Luxury class';
- if (budget > 500) {
- budget *= 0.9;
- } else if (budget > 100) {
- if (season === 'Summer') {
- car = 'Cabrio';
- budget *= 0.45;
- } else {
- budget *= 0.8;
- }
- carClass = 'Compact class';
- } else if (budget > 0) {
- if (season === 'Summer') {
- car = 'Cabrio';
- budget *= 0.35;
- } else {
- budget *= 0.65;
- }
- carClass = 'Economy class';
- }
- console.log(`${carClass}\n${car} - ${budget.toFixed(2)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement