function confirmEnding(str, target) {
if (str.substr(str.length - target.length, target.length) === target) return true;
else return false;
}
confirmEnding("Open sesame
", "same");
如confirmEnding("Open sesame", "same")
应该返回true.
时间: 2024-11-02 23:30:33