Javascript String jumble()

Description

Javascript String jumble()


String.prototype.jumble = (function () {
  return this.split(" ").map(function (T) {
    return T.substring(0, 1) + (T.length > 2 ? T.split("").slice(1, T.length - 1).sort(function () {
      return Math.round(Math.random()) - 0.5;
    }).join("") : "") + (T.length > 1 ? T.substring(T.length - 1) : "");
  }).join(" ");/* w  w w . ja v a2 s  .c o  m*/
});



PreviousNext

Related