Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function PrintMM(num){
- const spaceSymbol = '-';
- const wordSymbol = '*';
- let half = Math.floor(num / 2);
- let border = Math.ceil(num / 2);
- let result = '';
- for (let i = 0; i < border; i++) {
- result += spaceSymbol.repeat(Math.max(num - i, 0));
- result += wordSymbol.repeat(Math.max(i * 2 + num, 0));
- result += spaceSymbol.repeat(Math.max(num - i * 2, 0));
- result += wordSymbol.repeat(Math.max(i * 2 + num, 0 ));
- result += spaceSymbol.repeat(Math.max(num * 2 - i * 2, 0));
- result += wordSymbol.repeat(Math.max(i * 2 + num, 0));
- result += spaceSymbol.repeat(Math.max(num - i * 2, 0));
- result += wordSymbol.repeat(Math.max(i * 2 + num, 0 ));
- result += spaceSymbol.repeat(Math.max(num - i, 0));
- result += '\n';
- }
- for (let i = 0; i < border; i++) {
- result += spaceSymbol.repeat(Math.max(half - i, 0));
- result += wordSymbol.repeat(Math.max(num, 0));
- result += spaceSymbol.repeat(i * 2 + 1);
- result += wordSymbol.repeat(Math.max(num * 2 - 1 - 2 * i, 0));
- result += spaceSymbol.repeat(i * 2 + 1);
- result += wordSymbol.repeat(Math.max(num, 0));
- result += spaceSymbol.repeat(Math.max(num - 1 - i * 2, 0));
- result += wordSymbol.repeat(Math.max(num, 0));
- result += spaceSymbol.repeat(i * 2 + 1);
- result += wordSymbol.repeat(Math.max(num * 2 - 1 - 2 * i, 0));
- result += spaceSymbol.repeat(i * 2 + 1);
- result += wordSymbol.repeat(Math.max(num, 0));
- result += spaceSymbol.repeat(Math.max(half - i, 0));
- result += '\n';
- }
- console.log(result);
- }
- PrintMM(7);
Advertisement
Add Comment
Please, Sign In to add comment