Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. var myContent = `Paragraph one
  2.  
  3. Second paragraph
  4. new line`;
  5.  
  6. console.log(createContent(myContent)); // returns ['Paragraph one', 'Second paragraph', 'new line']
  7.  
  8. createContent = function(content) {
  9. paragraphs = [];
  10. if (content) {
  11. content.replace(/\n\n/, '\n').split(/\n/).forEach(function(val, ndx) {
  12. if (val.replace(' ', '').length) {
  13. paragraphs.push(val);
  14. }
  15. });
  16. } else {
  17. paragraphs = ["empty"];
  18. }
  19.  
  20. return paragraphs;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement