Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(n) {
- for (let i = 0; i < n; i++) {
- let currentRow = '';
- for (let j = 0; j < n * 2; j++) {
- if (i !== 0 && i !== n - 1 && j !== 0 && j !== n * 2 - 1) {
- currentRow += '/';
- } else {
- currentRow += '*';
- }
- }
- for (let k = 0; k < n; k++)
- {
- let x = ' ';
- if ((i === parseInt(n / 2) && n % 2 === 1 )||( i + 1 === n / 2 && n % 2 === 0))
- {
- x = '|';
- }
- currentRow += x;
- }
- for (let j = 0; j < n * 2; j++) {
- if (i !== 0 && i !== n - 1 && j !== 0 && j !== n * 2 - 1) {
- currentRow += '/';
- } else {
- currentRow += '*';
- }
- }
- console.log(currentRow);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement