Dynamic Suggestion chips

by onigetoc

JavaScript

var SChips = ['<- PREV', 'NEXT ->'];
var Chips2 = ['business>management', 'News>Entertainment News', 'business>Entrepreneurship'];

//var SuggestArr = Chips(Chips1, Chips2, 'Help')

if (typeof Chips2 != "undefined")
SChips = Chips(SChips, Chips2, 'Help');

console.log(SChips);

function Chips(Chs1, Chs2, pushit) {

  for (var i = 0; i < Chs2.length; i++) {
    Chs2[i] = Chs2[i].replace('>', ' ');
  }

  /* Chs2.map(function(item,index){
      return item.replace('>',' ')
    }); */

  let Chips = Chs1.concat(Chs2);

  Chips.push(pushit);

  return Chips

}

/* let cats = ['Bob', 'fuck'];
cats.push('Willy'); // ['Bob', 'Willy']
cats.push('Puff', 'George');
console.log(cats); */