You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
353 B
TypeScript
11 lines
353 B
TypeScript
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);
|