diff --git a/lib/endingStrings.ts b/lib/endingStrings.ts new file mode 100644 index 0000000..7c47f0a --- /dev/null +++ b/lib/endingStrings.ts @@ -0,0 +1,10 @@ +function solution1(str: string, ending: string): boolean { + if (ending === "") return true; + const startIndex = str.length - ending.length; + const subStr = str.substring(startIndex); + return subStr === ending; +} + +console.log(solution1("abcde", "cde"), true); +console.log(solution1("abcde", "abs"), false); +console.log(solution1("abcde", ""), true);