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