Advertisement
Spocoman

05. Square Frame

Jan 3rd, 2022
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(number) {
  2.  
  3.     for (let i = 0; i < number; i++) {
  4.         let angleChar = '';
  5.         let currentRow = '';
  6.         angleChar = i === 0 || i === number - 1 ? '+' : '|';
  7.         currentRow += angleChar;
  8.  
  9.         for (let x = 0; x < number - 2; x++) {
  10.             currentRow += ' -';
  11.         }
  12.         console.log(`${currentRow} ${angleChar}`);
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement