[bestSolution] search end string in another string my solution
This commit is contained in:
@@ -5,6 +5,10 @@ function solution1(str: string, ending: string): boolean {
|
|||||||
return subStr === ending;
|
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", "cde"), true);
|
||||||
console.log(solution1("abcde", "abs"), false);
|
console.log(solution1("abcde", "abs"), false);
|
||||||
console.log(solution1("abcde", ""), true);
|
console.log(solution1("abcde", ""), true);
|
||||||
|
|||||||
Reference in New Issue
Block a user