Additional solution for Rosetta Code: Split a character string

What is your hint or solution suggestion?

This is actually not that complicated as it seems. Create a loop that compares whether adjacent characters are equal to each other. If they are not equal, pass the index into an array. Once the array is created, use Array.map to slice the array at the indices (though you have to include 0 at the beginning).

Solution 1
function split(str) {
    var indices = []
    var i;
    for (i = 0; i < str.length-1; i++) {
    if(str[i]!=str[i+1]){
          indices.push(i+1)
        }
    }
    return splitOn(str,indices)
}

const splitOn = (slicable, indices) =>
  [0, ...indices].map((n, i, m) => slicable.slice(n, m[i + 1]));

Challenge: Split a character string based on change of character

Link to the challenge: