Intermediate Algorithm Scripting - Spinal Tap Case

This code is working just fine. but why don’t compiler take this code as solution. Iam i missing something here.Somebody clear me this out please.

Your code so far

function spinalCase(str) {
  let words = str.split(" ");
  let newArr = [];
  for(let i = 0;i<words.length;i++){
    newArr.push(words[i].toLowerCase());
  }
  let newArr1 = newArr.join("-");

  return newArr1;
}

spinalCase('This Is Spinal Tap');

Your browser information:

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

Challenge: Intermediate Algorithm Scripting - Spinal Tap Case

Link to the challenge:

I added this log statement to the end
console.log(spinalCase('AllThe-small Things'));
and it showed me the output from the function is:
allthe-small-things
but the expected output is
all-the-small-things

I am not sure yet about the other test cases, but I wanted to share this information with you since it will make you change the function anyway.

Edit: looks like you have a similar issue with the testcase for "“thisIsSpinalTap” and you are not transforming “The_Andy_Griffith_Show” this one either (you are keeping the underscores in place instead of replacing them with dashes)

Hi @Bunny007

As @hbar1st highlighted above, unfortunately, the tests expect you to do a lot more work than what is described in the problem. I suggest you run the tests and read through the failing tests. You will notice what I am referring to.

If you would like to see how your algorithm handles each of the test cases, you can add this line just before your return statement:

console.log(str + " -> " + newArr1);