确认末尾字符算法挑战
2018-06-28 10:51 更新
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
//substr
return target == str.substr(str.length-target.length,target.length);
//substring
//return target == str.substring(str.length-target.length,str.length);
}
confirmEnding("Bastian", "n");
以上内容是否对您有帮助:
更多建议: