[JavaScript][Programmers] 서울에서 김서방 찾기

조준형·2021년 9월 2일
0

Algorithm

목록 보기
109/142
post-thumbnail

🔎 서울에서 김서방 찾기

❓ 문제링크

https://programmers.co.kr/learn/courses/30/lessons/12919

📄 제출 코드

function solution(seoul) {
    return `김서방은 ${seoul.indexOf('Kim')}에 있다`;
}
let seoul = ["Jane", "Kim"];
console.log(solution(seoul));

seoul배열에서 Kim이 몇번째에 있는지 찾는 문제다.
Kim의 위치를 indexOf로 찾고, 백틱(``)을 이용해 한줄로 출력하였다.

profile
깃허브 : github.com/JuneHyung

0개의 댓글