```js
function dashes(str) {
    str =  str.replace(/_/g,' ').replace(/\s+/g,"-").toLowerCase();
    return str;
}

//test cases
dashes("thisCakeIsDelicious");
dashes("TheBig cat was Boastful");

```

the desired output respectively are: "this-cake-is-delicious" and "the-big-cat-was-boastful". 
How do i put a space between "TheBig" without contradicting the space before "Boastful". I have tried regex particular capital letters but as you can see Big and Boastful start with B.