File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 11export function drawGift ( size : number , symbol : string ) : string {
22 const topLines = [ ]
33 const bottomLines = [ ]
4+ const symbolPattern = symbol . repeat ( Math . max ( 0 , size - 2 ) )
45 for ( let i = 0 ; i < size - 1 ; ++ i ) {
56 let line = ''
67 if ( i === 0 ) {
78 line = '#' . repeat ( size )
89 } else {
9- line = `#${ symbol . repeat ( Math . max ( 0 , size - 2 ) ) } #${ symbol . repeat ( i - 1 ) } #`
10+ const symPtn = symbol . repeat ( i - 1 )
11+ line = `#${ symbolPattern } #${ symPtn } #`
1012 }
1113 const spaces = size - i - 1
1214 topLines . push ( `${ ' ' . repeat ( spaces ) } ${ line } ` )
1315 bottomLines . unshift ( line )
1416 }
15- // console.log(topLines)
16- // console.log(bottomLines)
17- const middleLine = size > 1 ? `\n${ '#' . repeat ( size ) } ${ symbol . repeat ( Math . max ( 0 , size - 2 ) ) } #\n` : '#'
17+ const barrer = '#' . repeat ( size )
18+ const middleLine = size > 1
19+ ? `\n${ barrer } ${ symbolPattern } #\n`
20+ : '#'
1821 const result = topLines . join ( '\n' ) + middleLine + bottomLines . join ( '\n' )
1922 return result + '\n'
2023}
You can’t perform that action at this time.
0 commit comments