Array.prototype.indexOf()

신승준·2022년 7월 11일
0

Mozilla


Syntax

arr.indexOf(searchElement[, fromIndex])

배열에서 searchElement를 찾아, 그 index를 반환한다. fromIndex부터 탐색을 시작한다. fromIndex를 적지 않으면 0 index부터 탐색을 시작한다.

프로그래머스 - 서울에서 김서방 찾기

function solution(seoul) {
    let result = seoul.indexOf("Kim", 0);
    
    return "김서방은 " + result + "에 있다";
}
profile
메타몽 닮음 :) email: alohajune22@gmail.com

0개의 댓글