WindFell

OunBussiness JS

Sep 26th, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function OwnBusiness(input){
  2.   let width=+input[0];
  3.   let length=+input[1];
  4.   let height=+input[2];
  5.  
  6.    let space = width * length * height;
  7.    let additionalSpace = 0;
  8.    let computers=0;
  9.  
  10.    let i=3;
  11.  
  12.     while (input[i] !== 'Done')
  13.     {
  14.         computers = +input[i];
  15.         i++;
  16.  
  17.         if (space >= computers)
  18.         {
  19.             space -= computers;
  20.             continue;
  21.         }
  22.  
  23.         additionalSpace = computers - space;
  24.         break;
  25.     }
  26.  
  27.     if (additionalSpace === 0)
  28.     {
  29.         console.log(`${space} Cubic meters left.`);
  30.     }
  31.     else
  32.     {
  33.         console.log(`No more free space! You need ${additionalSpace} Cubic meters more.`);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment