Javascript String hashtaggery()

Description

Javascript String hashtaggery()


String.prototype.hashtaggery = function(){
  var sentenceArray = this.split(' ');
  var hashArray = [];
  console.log(this.split(' '));
  for (var i = 0; i < sentenceArray.length; i++) {
    console.log(sentenceArray[i][0]);/*from  ww  w  .  j a v a 2s.c om*/
    if (sentenceArray[i][0] == "#") {
      console.log(sentenceArray[i]);
      hashArray.push(sentenceArray[i]);
    }
  }
  console.log(hashArray)
}

"a man a plan #trrriip #blah something else some words #dog #cat".hashtaggery();

"so #octothorpe".hashtaggery()



PreviousNext

Related