1. 程式人生 > >Confirm the Ending

Confirm the Ending

function bstr string -c ble pan 完成 glob str

檢查字符串結尾

判斷一個字符串(str)是否以指定的字符串(target)結尾。

如果是,返回true;如果不是,返回false。

當你完成不了挑戰的時候,記得開大招‘Read-Search-Ask‘。

這是一些對你有幫助的資源:

  • String.substr()
function confirmEnding(str, target) {
  // 請把你的代碼寫在這裏
  if(str.substr(str.length - target.length,str.length)===target){
    return true;
  }else{
    return false;
  }
  
}

confirmEnding(
"Bastian", "n");

Confirm the Ending