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