Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 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; } 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); |