javascript-tutorial / javascript-tutorial/ko.javascript.info

str.indexOf 오류

Open
#1,176 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
2k
Forks
852
PR merge metrics
No merged PRs in 30d

Description

https://ko.javascript.info/string에서
부문 문자열 찾기에

'부분 문자열 "id"는 위치 1에서 처음 등장하는데, 두 번째 인수에 2를 넘겨 "id"가 두 번째로 등장하는 위치가 어디인지 알아봅시다. '

라고 나오고 예제로는

let str = 'Widget with id';

alert( str.indexOf('id', 2) ) // 12

가 나와 있습니다.

하지만 두번째 인자는 n번째로 나오는 위치를 찾는 것이 아닌
인덱스가 n이상인 위치에서 처음으로 나오는 위치를 찾는 것입니다.
그 근거로 예제의 문자열을

let str = 'aWidget with id';

로 바꾼다면 13이 아닌 2가 출력되게 됩니다.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the Korean tutorial page at javascript.info/string and locate the substring-search section containing the str.indexOf('id', 2) example. Correct the Korean explanation so it describes the second argument as a starting index, update the example wording if needed, and verify that the surrounding explanation remains consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.