Advertisement
Guest User

judge

a guest
Sep 23rd, 2016
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. function solve([n]) {
  2. n = Number(n);
  3. let dash = '-';
  4. let sp = ' ';
  5. let inner = n - 2;
  6. if (n % 2 == 0 ) {
  7. n -= 1;
  8. }
  9. if (n <= 2){
  10. n = 3;
  11. }
  12.  
  13. for (let i = 0; i < n; i++) {
  14.  
  15. if (i == 0 || i == n - 1 || (n-1) / 2 == i) {
  16. console.log(`+${dash.repeat(inner)}+${dash.repeat(inner)}+`);
  17. }
  18. else {
  19. console.log(`|${sp.repeat(inner)}|${sp.repeat(inner)}|`);
  20. }
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement