Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function souvenirPrice(input) {
- let team = input.shift();
- let souvenir = input.shift();
- let quantity = Number(input.shift());
- let totalSum = 0;
- let price = 0;
- if (team === 'Argentina') {
- if (souvenir === 'flags') {
- price = 3.25 * quantity;
- } else if (souvenir === 'caps') {
- price = 7.2 * quantity;
- } else if (souvenir === 'posters') {
- price = 5.1 * quantity;
- } else if (souvenir === 'stickers') {
- price = 1.25 * quantity;
- } else {
- console.log('Invalid stock!');
- }
- } else if (team === 'Brazil') {
- if (souvenir === 'flags') {
- price = 4.2 * quantity;
- } else if (souvenir === 'caps') {
- price = 8.5 * quantity;
- } else if (souvenir === 'posters') {
- price = 5.35 * quantity;
- } else if (souvenir === 'stickers') {
- price = 1.2 * quantity;
- } else {
- console.log('Invalid stock!');
- }
- } else if (team === 'Croatia') {
- if (souvenir === 'flags') {
- price = 2.75 * quantity;
- } else if (souvenir === 'caps') {
- price = 6.9 * quantity;
- } else if (souvenir === 'posters') {
- price = 4.95 * quantity;
- } else if (souvenir === 'stickers') {
- price = 1.1 * quantity;
- } else {
- console.log('Invalid stock!');
- }
- } else if (team === 'Denmark') {
- if (souvenir === 'flags') {
- price = 3.1 * quantity;
- } else if (souvenir === 'caps') {
- price = 6.5 * quantity;
- } else if (souvenir === 'posters') {
- price = 4.8 * quantity;
- } else if (souvenir === 'stickers') {
- price = 0.9 * quantity;
- } else {
- console.log('Invalid stock!');
- }
- } else {
- console.log('Invalid country!');
- }
- if (price !== 0) {
- totalSum = quantity * price;
- console.log(`Pepi bought ${quantity} ${souvenir} of ${team} for ${totalSum.toFixed(2)} lv.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment