๐
String Length
String Length์
๋ฌธ ๋ฌธ์์ด +5pts
Problem
Write a function that returns the length of a string.
Examples
Input:
strLength("hello")Output:
5Explanation
์ด ๋ฌธ์ ๋ **๋ฌธ์์ด์ length ์์ฑ**์ ์ฌ์ฉํ์ฌ ๊ธธ์ด๋ฅผ ๊ตฌํ๋ ๋ฐฉ๋ฒ์ ํ์ตํฉ๋๋ค. ## ํต์ฌ ๊ฐ๋ : length ์์ฑ JavaScript์์ ๋ฌธ์์ด์ ๊ธธ์ด๋ `length` ์์ฑ์ผ๋ก ๊ฐ๋จํ ์ป์ ์ ์์ต๋๋ค. ### ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ ```javascript str.length ``` - ๋ฉ์๋๊ฐ ์๋ ์์ฑ์ด๋ฏ๋ก ๊ดํธ()๊ฐ ํ์ ์์ต๋๋ค - ๋ฌธ์์ด์ ๋ฌธ์ ์๋ฅผ ๋ฐํํฉ๋๋ค ### ์ฃผ์์ฌํญ ```javascript "hello".length // 5 "".length // 0 "์๋ ".length ...
View detailed explanation โKey Concepts
length ์์ฑ ๋ฌธ์์ด ๊ธฐ์ด ์์ฑ vs ๋ฉ์๋ ์ ๋์ฝ๋ ๊ธธ์ด
Time: O(1) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.