Confusion with Spinal Tap Case problem

Confusion with Spinal Tap Case problem


Hey guys, I’ve been doing the Spinal Tap Case algorithm and I am not able to detect the capital letter and then replace it with a -{the replaced capital letter}

so normally all the other test cases are working except where str is having a value something similar to “TheStr-Sa”

in this case I am not sure how to detect the beginning and then replace that with “-”

function spinalCase(str) {
  // "It's such a fine line between stupid, and clever."
  // --David St. Hubbins
  return str.replace(/(\s)|_/g, "-").toLowerCase();

spinalCase('AllThe-small Things');


Sticky bump, this is gonna be tough


Maybe this helps:


Here is a repl showing one way of getting the capital letters

using rgex we have a few methods we can use
hope it helps … will go have a look at my solution and see if this is what i did
just did this as you were looking for ways to find capital letters … it returns an array with the index of where all the capitals are

but if you follow the sudo code jenovs links to you should have no problem … checked my solution and while i use regex i dindnt use what i did in this repel