본문 바로가기
Portpolio/codingtest

프로그래머스 문자열안에 문자열 풀이

by Peter Choi 2025. 2. 16.
반응형

https://school.programmers.co.kr/learn/courses/30/lessons/120908

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

 

자바

class Solution {
    public int solution(String str1, String str2) {
        if(str1.contains(str2))
            return 1;
        else
            return 2;
    }
}

 

자바스크립트

function solution(str1, str2) {
    
    if (str1.includes(str2))
        return 1;
    else
        return 2;
}

 

javascript 부분은 아래의 stackoverflow 링크를 참고하세요.

https://stackoverflow.com/questions/52410662/why-is-this-returning-the-error-contains-is-not-a-function

 

Why is this returning the error .contains() is not a function

Am getting the error .contains() is not a function. Full code is here, probably too much to paste here so here's the relevant bits. Locations is globally set as well as query, then set state in the

stackoverflow.com

 

반응형

댓글