Ivankooo1

OwnBussines*

Jul 11th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. function OwnBussines(input){
  2. let w = Number(input.shift());
  3. let l = Number(input.shift());
  4. let h = Number(input.shift());
  5.  
  6. let Space = w * l * h;
  7.  
  8. let command = Number(input.shift());
  9. while(command !== 'Done'){
  10. let computers = Number(command)
  11. Space -= computers;
  12. if(Space <= 0){
  13. break;
  14. }
  15. command = input.shift();
  16. }
  17.  
  18. if(command === 'Done'){
  19. console.log(`${Space} Cubic meters left.`);
  20. }else{
  21. console.log(`No more free space! You need ${Math.abs(Space)} Cubic meters more.`);
  22. }
  23.  
  24.  
  25. }
  26. OwnBussines([
  27. 10,
  28. 1,
  29. 2,
  30. 4,
  31. 6,
  32. 'Done'
  33. ]);
Advertisement
Add Comment
Please, Sign In to add comment