Spinal Tap Case before each capital letter

Tell us what’s happening:

hello campers, my problem is this, on this exercise my regex is quite effective.

But I do not know how to put a dash before each capital letter when the word is pasted as thisIsSpinalTap

Can you put me on the path?

Your code so far

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
   let arr = str.split(/\_| |-/gi);
   return arr;

console.log(spinalCase('This Is Spinal Tap'));
console.log(spinalCase("Teletubbies say Eh-oh"));
console.log(spinalCase("AllThe-small Things"));

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36.

Link to the challenge:

Thanks you MDN :stuck_out_tongue_winking_eye:

replace(/([a-z])([A-Z])/g, ‘$1 $2’);