Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fuelTank(input) {
- let fuel = input[0].toLowerCase();
- let liter = Number(input[1]);
- if (fuel == 'diesel' || fuel == 'gasoline' || fuel == 'gas') {
- if (liter >= 25) {
- console.log(`You have enough ${fuel}.`);
- } else {
- console.log(`Fill your tank with ${fuel}!`);
- }
- } else {
- console.log('Invalid fuel!');
- }
- }
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- function fuelTank(input) {
- let fuel = input[0].toLowerCase();
- let liter = Number(input[1]);
- console.log(fuel == "diesel" || fuel == "gasoline" || fuel == "gas" ?
- (liter >= 25 ? `You have enough ${fuel}.` : `Fill your tank with ${fuel}!`) : 'Invalid fuel!');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement