Javascript String eachChar(c)

Description

Javascript String eachChar(c)


// http://www.codewars.com/kata/ruplesjs-number-3-string-eachchar

String.prototype.eachChar = function(c) {
  return this.valueOf() === ''
    ? this.valueOf()//from  w  w  w  . j a va2s .  c  om
    : typeof c === 'string'
      ? this.split('').join(c) + c
      : this.split('').map(c).join('');
}



PreviousNext

Related