So I have an array of strings(paragraphs) and the first phrase in each string represents the header. For example...
[
"The Lion, the Witch and the Wardrobe \n\ There was once a lion, a
witch and a wardrobe. The End"
]
As you can see, the header is separated by a line break \n\
. Is there a method I can use to grab the part of the string before the line break and store it in a variable?
I have a large number of these strings and so I'm looking for a solution that isn't just matching "The Lion, the Witch and the Wardrobe"
Thanks in advance guys.
Outcome I need...
let headers = [ "The Lion, the Witch and the Wardrobe", "example", "example" ]
let body = ["The was once a...", "example", "example"]