Intermediate Algorithm Scripting - Spinal Tap Case

Tell us what’s happening:
This is how I solved this problem but it’s completely different than the solutions. Anything wrong with how I complete the algorithm?

Your code so far

function spinalCase(str) {
  let spinalCaseRegex = /\w[a-z]+/g
  let result = str.match(spinalCaseRegex)
  return result.join("-").toLowerCase();
}

spinalCase('This Is Spinal Tap');
spinalCase("thisIsSpinalTap")

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36

Challenge: Intermediate Algorithm Scripting - Spinal Tap Case

Link to the challenge:

Since your code passes, I added spoiler tags.

1 Like

other than the fact that it is genius? Nope! :grinning:

1 Like

I think we need to add a new test case:

spinalCase(‘I Want A New Test Case’) should return i-want-a-new-test-case

This particular solution would fail this valid test case. The existing Guide solutions would pass this new test case.

1 Like

Doesn’t seem sporting to add a new test case though… :wink:

1 Like

haha tysm! I’m solving a lot of these questions in a different way than the solution. Would you recommend that I try to do it the solution way instead? The solution always seems to be completely different from how I solve it so I’m not sure if what I’m doing is wrong or right.

It is good that you are comparing and contrasting. But do your own thing, that’s your super-power. (So long as you are meeting the objectives that are laid out)

1 Like