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

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

Programmers

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

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

๋ฌธ์ž์—ด my_string๊ณผ ๋ฌธ์ž letter์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ฃผ์–ด์ง‘๋‹ˆ๋‹ค. my_string์—์„œ letter๋ฅผ ์ œ๊ฑฐํ•œ ๋ฌธ์ž์—ด์„ returnํ•˜๋„๋ก solution ํ•จ์ˆ˜๋ฅผ ์™„์„ฑํ•ด์ฃผ์„ธ์š”.


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

  • 1 โ‰ค my_string์˜ ๊ธธ์ด โ‰ค 100
  • letter์€ ๊ธธ์ด๊ฐ€ 1์ธ ์˜๋ฌธ์ž์ž…๋‹ˆ๋‹ค.
  • my_string๊ณผ letter์€ ์•ŒํŒŒ๋ฒณ ๋Œ€์†Œ๋ฌธ์ž๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ๋Œ€๋ฌธ์ž์™€ ์†Œ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•ฉ๋‹ˆ๋‹ค.

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

my_stringletterresult
"abcdef""f""abcde"
"BCBdbe""B""Cdbe"

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

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

  • "abcdef" ์—์„œ "f"๋ฅผ ์ œ๊ฑฐํ•œ "abcde"๋ฅผ returnํ•ฉ๋‹ˆ๋‹ค.

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

  • "BCBdbe" ์—์„œ "B"๋ฅผ ๋ชจ๋‘ ์ œ๊ฑฐํ•œ "Cdbe"๋ฅผ returnํ•ฉ๋‹ˆ๋‹ค.

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

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

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