I have an unusual request. Given a string like the following:
var a = "This is a sentance that has many words. I would like to split this to a few lines"
I need to insert a “\n” every fifth word. The string a can have any number of alphanumeric characters.
Can someone give me an idea how I could do this?
1 Answer