The input:
first line
second line third line
fourth line
The code:
let res = str.split('\n\n')
for (let result of res) {
res = `<p class="blockquote">${res.replace(/^> /gm, '')}</p>`
}
console.log(`text: ${res}`)
str.split('\n\n') outputs first line,second line third line,fourth line. What I expected.
Now I want to use the for loop to take each item and surround it with p tags. However, I get the following error:
TypeError: undefined is not a function
I'm not very experienced with ES6. Is there something wrong with the loop?