Algorithm not passing despite correct output

Tell us what’s happening:
I made a function to solve the algorithm case:
“Intermediate Algorithm Scripting: Spinal Tap Case”
And I expect it to pass since it outputs:

But I keep getting the error:


should return


Your code so far

function spinalCase(str) {
  let intermediate = str.replace(/([A-Z])/g, " $1");
  intermediate = intermediate.replace(/[_-]/, " ");
  let wordArray = intermediate.split(" ");
  let cleanedArray = [];
  wordArray.forEach(function(item) {
    if(item !== "") {
  let result = cleanedArray.join("-");
  result = result.toLowerCase();
  result = result.trim();
  return result;


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0.

Challenge: Spinal Tap Case

Link to the challenge:

it’s a display issue, you actually have _ between each word
try with that, see if the output changes
you can see it if you add console.log(str)

1 Like

added a g to find ALL undescores and replace them, and it worked.

Thanks! :slightly_smiling_face: