타입 챌린지 2693 - EndsWith

소파의 벨로그·2025년 4월 8일

타입챌린지

목록 보기
48/131

문제 링크

유사한 문제 풀이(StartsWith)

문제

두 정확한 string 타입을 받고 T가 U로 끝나는지를 반환하는 타입 EndsWith<T, U>를 구현하라

Implement EndsWith<T, U> which takes two exact string types and returns whether T ends with U

내 풀이

type EndsWith<T extends string, U extends string> = T extends `${string}${U}`?true:false

StartsWith과 비슷한 풀이다

0개의 댓글