From 56f7b520acc193d9a80ecd72b9048993959f4edd Mon Sep 17 00:00:00 2001 From: Vasily Guzov Date: Thu, 19 Sep 2024 22:50:20 +0300 Subject: [PATCH] [bestSolution] search end string in another string my solution --- lib/endingStrings.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/endingStrings.ts b/lib/endingStrings.ts index 7c47f0a..17237af 100644 --- a/lib/endingStrings.ts +++ b/lib/endingStrings.ts @@ -5,6 +5,10 @@ function solution1(str: string, ending: string): boolean { return subStr === ending; } +export function bestSolution(str: string, ending: string): boolean { + return str.endsWith(ending); +} + console.log(solution1("abcde", "cde"), true); console.log(solution1("abcde", "abs"), false); console.log(solution1("abcde", ""), true);