Spinal Tap Case - Can you help me to look at my simplified solution?

The solution provided by FCC all contain .replace().

My solution is a more simple one but as a beginner, I want to know if this solution will contain any bugs?

function spinalCase(str) {

  let arr = str.match(/[A-Z][a-z]+|[a-z]+/g)

  return arr.join("-").toLowerCase();


spinalCase("Teletubbies say Eh-oh");
1 Like

Hey @sausagefist!

The solution worked for me when I tested it.
You have to remember that the FCC solutions are only a few ways to solve the problem. For a lot of these algorithms, there are dozens of ways to solve the problem. As long as you test the solution and it works. Then you can call it a success.

There were a few algorithm problems where my solutions were not nearly as complicated as some of the FCC solutions but at the end of the day it worked.

Hope that helps!

1 Like