Let's say we have the following strings:
const str1 = 'aabbcc';
const str2 = 'aabbccaaddaaaaeeff';
I need to split them in order to obtain the following result:
mySplitFunction(str1, 'aa')//<--- ['aa','bbcc']
mySplitFunction(str1, 'bb')//<--- ['aa','bb', 'cc']
mySplitFunction(str2, 'aa')//<--- ['aa','bbcc', 'aa','dd', 'aa','aa', 'eeff']
mySplitFunction(str2, 'dd')//<--- ['aabbccaa','dd', 'aaaaeeff']
How would you do it?