๐Ÿ’ฅ[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค] ๋ฌธ์ž ๋ฐ˜๋ณต ์ถœ๋ ฅํ•˜๊ธฐ

Chobbyยท2022๋…„ 10์›” 12์ผ
2

Programmers

๋ชฉ๋ก ๋ณด๊ธฐ
82/349

๐Ÿงก๋ฌธ์ œ ์„ค๋ช…

๋ฌธ์ž์—ด my_string๊ณผ ์ •์ˆ˜ n์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์งˆ ๋•Œ, my_string์— ๋“ค์–ด์žˆ๋Š” ๊ฐ ๋ฌธ์ž๋ฅผ n๋งŒํผ ๋ฐ˜๋ณตํ•œ ๋ฌธ์ž์—ด์„ return ํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด๋ณด์„ธ์š”.


๐Ÿ’›์ œํ•œ์‚ฌํ•ญ

  • 1 โ‰ค my_string ๊ธธ์ด โ‰ค 50
  • 1 โ‰ค n โ‰ค 50
  • "my_string"์€ ์˜์–ด ๋Œ€์†Œ๋ฌธ์ž๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ’š์ž…์ถœ๋ ฅ ์˜ˆ

my_stringnresult
"hello"3"hhheeellllllooo"

๐Ÿ’™์ž…์ถœ๋ ฅ ์˜ˆ ์„ค๋ช…

์ž…์ถœ๋ ฅ ์˜ˆ #1

  • "hello"์˜ ๊ฐ ๋ฌธ์ž๋ฅผ ์„ธ ๋ฒˆ์”ฉ ๋ฐ˜๋ณตํ•œ "hhheeellllllooo"๋ฅผ return ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’œ๋‚˜์˜ ํ’€์ด

const solution = (my_string, n) => [...my_string].map(a => a.repeat(n)).join("")
profile
๋‚ด ์ง€์‹์„ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ๋Š” ๋Œ€๋‹ดํ•จ

0๊ฐœ์˜ ๋Œ“๊ธ€