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