📜

Trim String

Trim String
쉬움 문자열 +10pts

Problem

Write a function that removes whitespace from both ends of a string.

Examples

Input: trimString(" hello ")
Output: "hello"

Explanation

이 문제는 **trim() 메서드**로 문자열의 양 끝 공백을 제거하는 방법을 학습합니다. ## 핵심 개념: 공백 제거 trim()은 문자열의 시작과 끝에서 공백 문자를 제거합니다. ### 기본 사용법 ```javascript str.trim() ``` - 원본 문자열은 변경되지 않습니다 - 양쪽 끝의 공백만 제거 (중간 공백은 유지) ### 관련 메서드들 ```javascript " hello ".trim() // "hello" " hello ".trimStart() // "hello " " hello ...

View detailed explanation →

Key Concepts

trim 메서드 공백 제거 trimStart trimEnd
Time: O(n) Space: O(n)
solution.js
Ctrl + Enter
Run tests to see results here.