Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fishing(input) {
- let priceOfTheFish = 0.0;
- let fishCounter = 1;
- let testFinalPrice = 0.0;
- let difference = 0.0;
- let bonusPrice = 0.0;
- while (!"Stop"){
- fishKilogrames = Number(input.shift());
- for ( i = fishName.length() - 1; i >= 0; i--) {
- symbolSum = String.fromCharAt(fishName);
- priceOfTheFish = symbolSum + priceOfTheFish;
- testFinalPrice = priceOfTheFish / fishKilogrames;
- }
- if (fishCounter != 3){
- difference = difference + testFinalPrice;
- }else {
- bonusPrice = bonusPrice + testFinalPrice;
- }
- priceOfTheFish = 0;
- testFinalPrice = 0;
- fishCounter++;
- if (fishCounter == catchedFish + 1){
- console.log(`Lyubo fulfilled the quota!`);
- break;
- }
- fishName = input.shift();
- }
- if (difference > bonusPrice){
- realFinalPrice = difference - bonusPrice;
- console.log(`Lyubo lost ${realFinalPrice.toFixed(2)} leva today. `);
- }else {
- console.log(`Lyubo's profit from ${fishCounter - 1} fishes is ${bonusPrice - difference} leva.`);
- }
- }
- fishing([ '3', 'catfish', '70', 'carp', '20', 'tench', '14' ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement