๐ŸŒ  ๋ฌธ์ œ

๋ฌธ์ž์—ด ๋ฐฐ์—ด 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;
}

+ Recent posts