美文网首页
palindrome

palindrome

作者: 殷众 | 来源:发表于2016-04-05 11:46 被阅读17次
String.prototype.palindrome = function (type){
  const _arr = this.split('')
  if (type === 'odd') {
    return this + _arr.reverse().slice(1, _arr.length).join('')
  }
  return this + _arr.reverse().join('')
}

相关文章

网友评论

      本文标题:palindrome

      本文链接:https://www.haomeiwen.com/subject/zuvelttx.html