Advertisement
vborislavova

06. Building - Nested Loops - Lab

Mar 21st, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function buildingNumbers(input) {
  2.     let floors = Number(input.shift());
  3.     let count = Number(input.shift());
  4.    
  5.     for (let row = floors; row >= 1; row--) {
  6.         let result = "";
  7.         let type = "";
  8.         if(row % 2 == 0) {
  9.             type = "O";
  10.         } else {
  11.             type = "A";
  12.         }
  13.         if (row == floors) {
  14.             type = "L";
  15.         }
  16.         for (let col = 0; col < count; col++) {
  17.             result += `${type}${row}${col} `;
  18.         }
  19.         console.log(result);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement