Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function suitcasesLoad(input){
- let capacity = Number(input.shift());
- let countLuggade =0;
- let command;
- while((command = input.shift())!== "End"){
- let volumeTrunk = Number(command);
- countLuggade++;
- if(countLuggade % 3 == 0){
- volumeTrunk *= 1.10;
- }
- if(volumeTrunk > capacity){
- countLuggade --;
- break;
- }
- capacity -= volumeTrunk;
- command = input.shift();
- }
- if (command == "End"){
- console.log("Congratulations! All suitcases are loaded!");
- }else{
- console.log("No more space!");
- }
- console.log(`Statistic: ${countLuggade} suitcases loaded.`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement