-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Open
Description
2693 - EndsWith
EndsWith is almost identical to yesterday's challenge. So. A little break from the onslaught of other challenges never hurt anyone
🎥 Video Explanation
🔢 Code
// ============= Test Cases =============
import type { Equal, Expect } from './test-utils'
type A1 = EndsWith<'abc', 'bc'>
type B1 = true
type C1 = Expect<Equal<A1, B1>>;
type A2 = EndsWith<'abc', 'abc'>
type B2 = true
type C2 = Expect<Equal<A2, B2>>;
type A3 = EndsWith<'abc', 'd'>
type B3 = false
type C3 = Expect<Equal<A3, B3>>;
// ============= Your Code Here =============
type EndsWith<
T extends string,
U extends string
> =
T extends `${string}${U}`
? true
: false;➕ More Solutions
For more video solutions to other challenges: see the umbrella list! #21338
Metadata
Metadata
Assignees
Labels
No labels