728x90
๋ฐ์ํ
๋ฌธ์ ์ค๋ช
๋ฌธ์์ด ๋ฐฐ์ด strlist๊ฐ ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง๋๋ค. strlist ๊ฐ ์์์ ๊ธธ์ด๋ฅผ ๋ด์ ๋ฐฐ์ด์ retrunํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์.
์ ํ์ฌํญ
- 1 ≤ strlist ์์์ ๊ธธ์ด ≤ 100
- strlist๋ ์ํ๋ฒณ ์๋ฌธ์, ๋๋ฌธ์, ํน์๋ฌธ์๋ก ๊ตฌ์ฑ๋์ด ์์ต๋๋ค.
์ ์ถ๋ ฅ ์strlistresult
["We", "are", "the", "world!"] | [2, 3, 3, 6] |
["I", "Love", "Programmers."] | [1, 4, 12] |
์ ์ถ๋ ฅ ์ ์ค๋ช
์ ์ถ๋ ฅ ์ #1
- ["We", "are", "the", "world!"]์ ๊ฐ ์์์ ๊ธธ์ด์ธ [2, 3, 3, 6]์ returnํฉ๋๋ค.
์ ์ถ๋ ฅ ์ #2
- ["I", "Love", "Programmers."]์ ๊ฐ ์์์ ๊ธธ์ด์ธ [1, 4, 12]์ returnํฉ๋๋ค.
๋ดํ์ด
function solution(strlist) {
return strlist.map(value => value.length);
}
๐ก
์ด์ ์ ํ์ฉํ๋ map์ ์ด์ฉํ ๋ฌธ์ ์๋ค
๊ธธ์ด๊ฐ ํ์ํ ๋ถ๋ถ์ด length๋ก !
๋ฐ์ํ
'์๊ณ ๋ฆฌ์ฆ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] LV0 ํธ์ง (0) | 2023.01.09 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] ์ํ ๋๋ฌผ ์ฐพ๊ธฐ (0) | 2023.01.09 |
[ํ๋ก๊ทธ๋๋จธ์ค] LV0 ๋์ด์ถ๋ ฅ (0) | 2023.01.07 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ฐฐ์ด๋ค์ง๊ธฐ (0) | 2023.01.06 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์ซ์ ๋น๊ต (0) | 2023.01.06 |