Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var myContent = `Paragraph one
- Second paragraph
- new line`;
- console.log(createContent(myContent)); // returns ['Paragraph one', 'Second paragraph', 'new line']
- createContent = function(content) {
- paragraphs = [];
- if (content) {
- content.replace(/\n\n/, '\n').split(/\n/).forEach(function(val, ndx) {
- if (val.replace(' ', '').length) {
- paragraphs.push(val);
- }
- });
- } else {
- paragraphs = ["empty"];
- }
- return paragraphs;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement