vborislavova

02. Spaceship - sampleExam

Mar 28th, 2020
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function spaceship(input) {
  2.     let width = Number(input.shift());
  3.     let length = Number(input.shift());
  4.     let height = Number(input.shift());
  5.     let average = Number(input.shift());
  6.  
  7.     let volumeRacket = width * length * height;
  8.     let volumeRoom = 2 * 2 * (average + 0.40);
  9.     let people = Math.floor(volumeRacket / volumeRoom);
  10.  
  11.     if (people >= 3 && people <= 10) {
  12.        console.log(`The spacecraft holds ${people} astronauts.`);
  13.     } else if (people < 3) {
  14.         console.log("The spacecraft is too small.");
  15.     } else if (people > 10) {
  16.         console.log("The spacecraft is too big.");
  17.     }
  18. }
Add Comment
Please, Sign In to add comment