script.js 780 B

123456789101112131415161718192021222324
  1. //Синий пояс Number: flats
  2. function calculateEntranceandFloor(apartmentNumber, numberOfFloors, numberOfApartmentceFloor) {
  3. let apartForEntrance = numberOfFloors * numberOfApartmentceFloor;
  4. console.log(apartForEntrance);
  5. let apartEntrance = Math.ceil(apartmentNumber / apartForEntrance);
  6. console.log(apartEntrance);
  7. let apartmentFloor = Math.ceil(apartmentNumber / numberOfApartmentceFloor);
  8. console.log(apartmentFloor % numberOfFloors);
  9. if (!(apartmentFloor % numberOfFloors)) {
  10. console.log(`Floor - ${numberOfFloors} and Entrance - ${apartEntrance}` );
  11. } else {
  12. console.log(`Floor - ${apartmentFloor % numberOfFloors} and Entrance - ${apartEntrance}` );
  13. }
  14. }
  15. calculateEntranceandFloor( 5, 9, 4);