๐ ๋ฌธ์
๋ฌธ์์ด ๋ฐฐ์ด strlist๊ฐ ๋งค๊ฐ๋ณ์๋ก ์ฃผ์ด์ง๋๋ค. strlist ๊ฐ ์์์ ๊ธธ์ด๋ฅผ ๋ด์ ๋ฐฐ์ด์ retrunํ๋๋ก solution ํจ์๋ฅผ ์์ฑํด์ฃผ์ธ์.
๐ ์ ํ์ฌํญ
- 1 ≤ strlist ์์์ ๊ธธ์ด ≤ 100
strlist๋ ์ํ๋ฒณ ์๋ฌธ์, ๋๋ฌธ์, ํน์๋ฌธ์๋ก ๊ตฌ์ฑ๋์ด ์์ต๋๋ค.
๐ ์ ์ถ๋ ฅ ์
strlist result
["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) {
let answer_array = [];
while (strlist.length != 0) {
answer_array.push(strlist.shift().length)
}
return answer_array;
}
'๐งฉ Algorithm > ๐ง JavaScript' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] ์ผ๊ฐํ์ ์์ฑ์กฐ๊ฑด (1) (0) | 2023.04.11 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] ์ค๋ณต๋ ๋ฌธ์ ์ ๊ฑฐ (0) | 2023.04.11 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์ปจํธ๋กค ์ ํธ (0) | 2023.04.11 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์์ธ์๋ถํด (0) | 2023.04.10 |
[ํ๋ก๊ทธ๋๋จธ์ค] ์จ์ด์๋ ์ซ์์ ๋ง์ (1) (0) | 2023.04.10 |