Intermediate Algorithm Scripting - Spinal Tap Case

Tell us what’s happening:
I’m unable to pass this test case
" spinalCase("thisIsSpinalTap") should return the string this-is-spinal-tap"

How to convert non-spaced sentence with ’ - ’ ??

I’m getting this O/p : - thisisspinaltap

Your code so far

function spinalCase(str) {
  let space = (/\s+|_+/g);
  let string = str
  .replace(space,"-")
  .toLowerCase();
  return string;
}

console.log(spinalCase('thisIsSpinalTap'));

Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Spinal Tap Case

Link to the challenge:

it would be helpefull if you can share your output ,
however i don’t think you’re changing the string since there’s no white space to replace with “-” , instead you should find a way to split the string into words where there’s a upper case letter and then join it by hyphens and change it lower case.

spinalCase(“thisIsSpinalTap”) should return the string

this-is-spinal-tap
```"

spinalCase(“AllThe-small Things”)


should return the string  all-the-small-things

. // tests completed // console output
 this-is-spinal-tap


//I'm getting this output!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.