π
Ends With
Ends Withμ¬μ λ¬Έμμ΄ +10pts
Problem
Write a function that checks if a string ends with a given suffix.
Examples
Input:
endsWith("hello", "lo")Output:
trueExplanation
μ΄ λ¬Έμ λ **endsWith() λ©μλ**λ‘ λ¬Έμμ΄μ λμ νμΈνλ λ°©λ²μ νμ΅ν©λλ€. ## ν΅μ¬ κ°λ : μ λ―Έμ¬ νμΈ endsWith()λ λ¬Έμμ΄μ΄ νΉμ λ¬Έμμ΄λ‘ λλλμ§ νμΈν©λλ€. ### κΈ°λ³Έ μ¬μ©λ² ```javascript str.endsWith(searchString) str.endsWith(searchString, length) ``` - searchString: μ°Ύμ μ λ―Έμ¬ - length: κ²μν λ¬Έμμ΄ κΈΈμ΄ (κΈ°λ³Έκ°: str.length) ### νμ© μμ ```javascript "hello".endsWit...
View detailed explanation βKey Concepts
endsWith λ©μλ μ λ―Έμ¬ νμΈ νμΌ νμ₯μ κ²μ¬ ES6 λ©μλ
Time: O(m) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.