You can do following.
First convert array to string:- "abcdababa" (using .join(""))
Now split string with "a" as seprator:- ["","bcd","b","b",""] (using .split("a"))
Now prepend "a" to all the element:- ["a","abcd","ab","ab","a"] (using .map(x=>"a"+x))
Now split all element with ""(empty string) as seprator:- [["a"],["a","b","c","d"],["a","b"],["a","b"],["a"]] (using .split("")) (this step will be inside map function)
Now remove first element(as it is not part of your string):- [["a","b","c","d"],["a","b"],["a","b"],["a"]] (using .shift())
var arr = ["a","b","c","d","a","b","a","b","a"];
var x1 = arr.join("").split("a").map(x => {
x = "a" + x;
return x.split("");
});
x1.shift();
console.log(x1);
forloop and check if the current character is"a". Please read: How much research effort is expected of Stack Overflow users?