FreeCodeCamp学习--Confirm the Ending

来源:互联网 发布:美容软件app推荐 编辑:程序博客网 时间:2024/06/03 12:28


Confirm the Ending


检查一个字符串(str)是否以指定的字符串(target)结尾。

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

function confirmEnding(str, target) {  // "Never give up and good luck will find you."  // -- Falcor  var s=target.length;  var s1=str.length;  if(str.substr(s1-s)==target)      return true;    return false;}confirmEnding("Bastian", "n");


Confirm the Ending


检查一个字符串(str)是否以指定的字符串(target)结尾。

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

0 0
原创粉丝点击