SOURCE

function endsWith(str, substr) {
    let ans = str.slice((str.length - substr.length), str.length);
    if (ans === substr) {
        return ans;
    }
    return 0;
}

s = "hello";
ans = endsWith(s, "llo");
console.log(ans);
console 命令行工具 X clear

                    
>
console