keywordsformat.js 346 B

123456789101112131415161718
  1. /** Example */
  2. var all = 'keywords here';
  3. var output = '', line = '';
  4. all.forEach(function (item) {
  5. if (12 + 1 + line.length + 1 + item.length + 4 > 120) {
  6. output += "\n" + " '" + line + " ' +";
  7. line = '';
  8. return;
  9. }
  10. if (line) {
  11. line = line + ' ' + item;
  12. } else {
  13. line = item;
  14. }
  15. });
  16. console.log(output);