Advertisement
PowerCell46

Building JS

Oct 7th, 2022
1,004
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function building(input) {
  2.     let numberOfFloors = Number(input[0]);
  3.     let numberOfRoomsInAFloor = Number(input[1]);
  4.    
  5.    
  6.     for(let floor = numberOfFloors; floor > 0; floor--) {
  7.         let result = ""; // за да разпечата резултата на 1 ред
  8.         let result1 = ""; // за да разпечата резултата на 1 ред
  9.        
  10.         if(floor === numberOfFloors) {
  11.         for(let room = 0; room <= (numberOfRoomsInAFloor - 1); room++) {
  12.             result1 += ("L" + floor + room + " ");
  13.             if(room === (numberOfRoomsInAFloor - 1)) {
  14.                 console.log(result1);
  15.             }
  16.         } continue;
  17.         }
  18.         if(floor % 2 === 0) {
  19.             //offices
  20.             for(let room = 0; room <= (numberOfRoomsInAFloor - 1); room++) {
  21.             result += ("O" + floor + room + " ");
  22.             }
  23.    
  24.         } else if(floor % 2 === 1) {
  25.             //apartments
  26.             for(let room = 0; room <= (numberOfRoomsInAFloor - 1); room++) {
  27.             result += ("A" + floor + room + " ");
  28.             }
  29.         }
  30.     console.log(result);
  31.     }
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement